Module: check_mk
Branch: master
Commit: 92a2be71386b204afe1e1192d1ed1ce61d9b6938
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=92a2be71386b20…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Mon Feb 5 09:40:24 2018 +0100
checktestlib: Rudimentary container classes for discovery results and entries
Change-Id: I84abb0c9a05239dbd0b8f3ea09b8b35b792984f5
---
tests/checks/checktestlib.py | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/tests/checks/checktestlib.py b/tests/checks/checktestlib.py
index 8493b6e..109d9f7 100644
--- a/tests/checks/checktestlib.py
+++ b/tests/checks/checktestlib.py
@@ -1,7 +1,7 @@
import types
class Tuploid(object):
- """Base class for values with variadic tuple
representations"""
+ """Base class for values with (potentially variadic) tuple
representations"""
def __eq__(self, other_value):
if isinstance(other_value, self.__class__):
@@ -126,3 +126,23 @@ class CheckResult(object):
for subresult in self.subresults:
perfdata += subresult.perfdata if subresult.perfdata else []
return perfdata
+
+
+class DiscoveryEntry(Tuploid):
+
+ def __init__(self, entry):
+ item, default_params = entry
+ assert type(item) in [ str. types.NoneType ]
+ self.item = item
+ self.default_params = default_params
+
+ def tuple(self):
+ return (item, default_params)
+
+
+class DiscoveryResult(object):
+
+ def __init__(self, result):
+ self.entries = []
+ for entry in result:
+ self.entries.append(DiscoveryEntry(entry))