Module: check_mk
Branch: master
Commit: 15db0491bd2cf714ee6128c02bbb7194f2e94d3b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=15db0491bd2cf7…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Mon Dec 18 09:51:15 2017 +0100
Check tests: Introduce class for handling compound check results as returned by the yield
API
Change-Id: Iaa4c451851ea1c5100c096005ae6f955d5a063d0
---
tests/checks/checktestlib.py | 9 +++++++++
tests/checks/test_statgrab_cpu_check.py | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/tests/checks/checktestlib.py b/tests/checks/checktestlib.py
index ad32453..39a0b98 100644
--- a/tests/checks/checktestlib.py
+++ b/tests/checks/checktestlib.py
@@ -37,3 +37,12 @@ class BasicCheckResult(object):
assert result.infotext == expected_result["infotext"]
if "perfdata" in expected_result:
assert result.perfdata == expected_result["perfdata"]
+
+
+class CompoundCheckResult(object):
+ """A check result consisting of multiple subresults, as returned by
yield-style checks"""
+
+ def __init__(self, result):
+ self.subresults = []
+ for subresult in result:
+ self.subresults.append(BasicCheckResult(*subresult))
diff --git a/tests/checks/test_statgrab_cpu_check.py
b/tests/checks/test_statgrab_cpu_check.py
index e9e6942..446aa27 100644
--- a/tests/checks/test_statgrab_cpu_check.py
+++ b/tests/checks/test_statgrab_cpu_check.py
@@ -31,4 +31,4 @@ def test_statgrab_cpu_check(check_manager, monkeypatch, time_to_info,
params, ex
except MKCounterWrapped:
pass
monkeypatch.setattr("time.time", lambda: 60)
- subresults = [ checktestlib.BasicCheckResult(*subresult) for subresult in
check.run_check(None, params, time_to_info(60)) ]
+ result = checktestlib.CompoundCheckResult(check.run_check(None, params,
time_to_info(60)))