Module: check_mk
Branch: master
Commit: 3d1f794bbfe7b027046354dc026616eb7fc3c84d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3d1f794bbfe7b0…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Mon Dec 18 10:05:44 2017 +0100
Add docstrings
Change-Id: I38d6183d217772a046d4839bd5906035042a40d7
---
tests/checks/checktestlib.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tests/checks/checktestlib.py b/tests/checks/checktestlib.py
index 39a0b98..f7618d1 100644
--- a/tests/checks/checktestlib.py
+++ b/tests/checks/checktestlib.py
@@ -8,6 +8,7 @@ class BasicCheckResult(object):
def __init__(self, status, infotext, perfdata=None):
"""We perform some basic consistency checks during
initialization"""
+
assert status in [0,1,2,3]
assert type(infotext) == str
assert "\n" not in infotext
@@ -31,6 +32,13 @@ class BasicCheckResult(object):
self.perfdata = perfdata
def assert_result(self, expected_result):
+ """Assert that 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.
+ """
+
if "status" in expected_result:
assert result.status == expected_result["status"]
if "infotext" in expected_result:
@@ -43,6 +51,8 @@ class CompoundCheckResult(object):
"""A check result consisting of multiple subresults, as returned by
yield-style checks"""
def __init__(self, result):
+ """Initializes a list of subresults using
BasicCheckResult"""
+
self.subresults = []
for subresult in result:
self.subresults.append(BasicCheckResult(*subresult))