Module: check_mk
Branch: master
Commit: 226ad44b9097d13c7a7ce6fd929baae48bae7e24
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=226ad44b9097d1…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Wed Dec 13 18:23:00 2017 +0100
Check tests: Move logic for result assertion to BasicCheckResult class
Change-Id: I8adc2132aa070ac04d17e01eafd9734ed089f145
---
tests/checks/checktestlib.py | 7 +++++++
tests/checks/test_df_check.py | 7 +------
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/tests/checks/checktestlib.py b/tests/checks/checktestlib.py
index ee82e1d..ad32453 100644
--- a/tests/checks/checktestlib.py
+++ b/tests/checks/checktestlib.py
@@ -30,3 +30,10 @@ class BasicCheckResult(object):
assert all(type(value) in [int, float, type(None)] for value in
entry[2:])
self.perfdata = perfdata
+ def assert_result(self, expected_result):
+ if "status" in expected_result:
+ assert result.status == expected_result["status"]
+ if "infotext" in expected_result:
+ assert result.infotext == expected_result["infotext"]
+ if "perfdata" in expected_result:
+ assert result.perfdata == expected_result["perfdata"]
diff --git a/tests/checks/test_df_check.py b/tests/checks/test_df_check.py
index 6331e43..57f5abd 100644
--- a/tests/checks/test_df_check.py
+++ b/tests/checks/test_df_check.py
@@ -267,9 +267,4 @@ 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)))
- if "status" in expected_result:
- assert result.status == expected_result["status"]
- if "infotext" in expected_result:
- assert result.infotext == expected_result["infotext"]
- if "perfdata" in expected_result:
- assert result.perfdata == expected_result["perfdata"]
+ result.assert_result(expected_result)