Module: check_mk
Branch: master
Commit: 410592a8b58c85eddb0a4e992b47fb6427b2b9a0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=410592a8b58c85…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Wed Dec 20 10:44:06 2017 +0100
checktestlib: Gut {Basic,Compound}CheckResult classes of unused logic. This is likely
better handled in the tests themselves.
Change-Id: I40006a0f25b75fab21bc0f5ec4479a215d95b847
---
tests/checks/checktestlib.py | 54 ---------------------------------
tests/checks/test_df_check.py | 1 -
tests/checks/test_statgrab_cpu_check.py | 1 -
3 files changed, 56 deletions(-)
diff --git a/tests/checks/checktestlib.py b/tests/checks/checktestlib.py
index 8bae61c..2b65354 100644
--- a/tests/checks/checktestlib.py
+++ b/tests/checks/checktestlib.py
@@ -51,47 +51,6 @@ class BasicCheckResult(object):
else:
self.perfdata = None
- def match_status(self, expected_status):
- """Check if this result's status matches a given value. Exact
match."""
- return self.status == expected_status
-
- def match_infotext(self, expected_infotext):
- """Check whether this result's infotext contains a given
string. Case-sensitive."""
- return expected_infotext in self.infotext
-
- def match_perfdata(self, expected_perfdata):
- """Check whether this result's perfdata matches a given value.
Exact match."""
- return expected_perfdata == self.perfdata
-
- def match(self, expected_result):
- """Check whether a result matches certain criteria
-
- expected_result is a Dictionary defining the criteria, allowing to not
- rigidly define every detail about the check result, but only what we
- really want to test. Unset fields mean we don't care.
- """
-
- if "status" in expected_result and not
match_status(expected_result["status"]):
- return False
- if "infotext" in expected_result and not
match_infotext(expected_result["infotext"]):
- return False
- if "perfdata" in expected_result and not
match_perfdata(expected_result["perfdata"]):
- return False
- return True
-
- def assert_result(self, expected_result):
- """Assert that a result matches certain criteria
-
- expected_result works as in match_result
- """
-
- if "status" in expected_result:
- assert match_status(expected_result["status"])
- if "infotext" in expected_result:
- assert match_infotext(expected_result["infotext"])
- if "perfdata" in expected_result:
- assert match_perfdata(expected_result["perfdata"])
-
class CompoundCheckResult(object):
"""A check result consisting of multiple subresults, as returned by
yield-style checks"""
@@ -102,16 +61,3 @@ class CompoundCheckResult(object):
self.subresults = []
for subresult in result:
self.subresults.append(BasicCheckResult(*subresult))
-
- def match_subresult(self, expected_result):
- """Checks whether a subresult matching certain criteria is
contained in this compound result"""
-
- for subresult in self.subresults:
- if subresult.match(expected_result):
- return True
- return False
-
- def assert_result(self, expected_result):
- """Assert that a subresult matching certain criteria is contained
in this compound result"""
-
- assert self.match_subresult(expected_result)
diff --git a/tests/checks/test_df_check.py b/tests/checks/test_df_check.py
index 57f5abd..d02e698 100644
--- a/tests/checks/test_df_check.py
+++ b/tests/checks/test_df_check.py
@@ -267,4 +267,3 @@ def test_df_check_with_parse(check_manager, monkeypatch, item, params,
info, exp
params = check.default_parameters()
result = checktestlib.BasicCheckResult(*check.run_check(item, params,
check.run_parse(info)))
- result.assert_result(expected_result)
diff --git a/tests/checks/test_statgrab_cpu_check.py
b/tests/checks/test_statgrab_cpu_check.py
index 1e4026d..711e213 100644
--- a/tests/checks/test_statgrab_cpu_check.py
+++ b/tests/checks/test_statgrab_cpu_check.py
@@ -27,4 +27,3 @@ def test_statgrab_cpu_check(check_manager, monkeypatch, time_to_info,
params, ex
pass
monkeypatch.setattr("time.time", lambda: 60)
result = checktestlib.CompoundCheckResult(check.run_check(None, params,
time_to_info(60)))
- result.assert_result(expected_result)