Module: check_mk
Branch: master
Commit: 6c4182eb858a05e677ab110c122f6ae51dfc0c23
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6c4182eb858a05…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Jun 20 12:57:54 2018 +0200
Add class for basic sanity check of item state 2-tuple
Change-Id: I0c858bf0b7899c9acbc123bee89e372f6ad6687c
---
tests/unit/checks/checktestlib.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/tests/unit/checks/checktestlib.py b/tests/unit/checks/checktestlib.py
index 7370b1e..98bfafc 100644
--- a/tests/unit/checks/checktestlib.py
+++ b/tests/unit/checks/checktestlib.py
@@ -241,3 +241,24 @@ def assertDiscoveryResultsEqual(actual, expected):
assert enta == ente, "%r != %r" % (enta, ente)
+class BasicItemState(object):
+ """Item state as returned by get_item_state
+
+ We assert that we have exactly two values,
+ where the first one is either float or int.
+ """
+ def __init__(self, *args):
+ if len(args) == 1:
+ args = args[0]
+ msg = "BasicItemStates expected 2-tuple (time_diff, value) - not %r"
+ assert isinstance(args, tuple), msg % args
+ assert len(args) == 2, msg % args
+ self.time_diff, self.value = args
+
+ time_diff_type = type(self.time_diff)
+ msg = "time_diff should be of type float/int - not %r"
+ assert time_diff_type in (float, int), msg % time_diff_type
+ # We do allow negative time diffs.
+ # We want to ba able to test time anomalies.
+
+