Module: check_mk
Branch: master
Commit: 8b68b02c62d66f66df8449d00f6b20330a90f0ac
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8b68b02c62d66f…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Jan 17 11:41:50 2019 +0100
test_ps: Added match_groups scenario
Change-Id: I6de6a86b8920a35447fafdd3d537129c8c580fb8
---
tests/unit/checks/test_ps.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tests/unit/checks/test_ps.py b/tests/unit/checks/test_ps.py
index b929185..986f66b 100644
--- a/tests/unit/checks/test_ps.py
+++ b/tests/unit/checks/test_ps.py
@@ -330,6 +330,19 @@ def test_process_matches(check_manager, ps_line, ps_pattern,
user_pattern, resul
ps_pattern, user_pattern) == result
+(a)pytest.mark.parametrize("ps_line_line, ps_pattern, user_pattern, match_groups,
result", [
+ (["test", "ps"], "", None, None, True),
+ (["test", "123_foo"], "~.*/(.*)_foo", None,
['123'], False),
+ (["test", "/a/b/123_foo"], "~.*/(.*)_foo", None,
['123'], True),
+ (["test", "123_foo"], "~.*\\\\(.*)_foo", None,
['123'], False),
+ (["test", "c:\\a\\b\\123_foo"], "~.*\\\\(.*)_foo",
None, ['123'], True),
+])
+def test_process_matches_match_groups(check_manager, ps_line, ps_pattern, user_pattern,
match_groups, result):
+ check = check_manager.get_check("ps")
+ assert
check.context["process_matches"]([check.context["ps_info"](ps_line[0])]
+ ps_line[1:],
+ ps_pattern, user_pattern, match_groups) ==
result
+
+
@pytest.mark.parametrize("text, result", [
("12:17", 737),
("55:12:17", 198737),