Module: check_mk
Branch: master
Commit: ebf08b6ab057098296fc6f51a702a7181d2d66af
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ebf08b6ab05709…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Wed Jan 24 12:57:54 2018 +0100
__repr__ for PerfValue and BasicCheckResult
Change-Id: I07f76c821a028257f0474d34bf179a0536bf9a05
---
tests/checks/checktestlib.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tests/checks/checktestlib.py b/tests/checks/checktestlib.py
index 097f25e..8493b6e 100644
--- a/tests/checks/checktestlib.py
+++ b/tests/checks/checktestlib.py
@@ -48,6 +48,10 @@ class PerfValue(Tuploid):
def tuple(self):
return (self.key, self.value, self.warn, self.crit, self.minimum, self.maximum)
+ def __repr__(self):
+ return "PerfValue(%s, %s, %s, %s, %s, %s)" % (self.key, self.value,
self.warn,
+ self.crit, self.minimum,
self.maximum)
+
class BasicCheckResult(Tuploid):
"""
@@ -61,7 +65,7 @@ class BasicCheckResult(Tuploid):
def __init__(self, status, infotext, perfdata=None):
"""We perform some basic consistency checks during
initialization"""
- assert status in [0,1,2,3]
+ assert status in [0, 1, 2, 3]
assert type(infotext) == str
assert "\n" not in infotext
self.status = status
@@ -71,8 +75,11 @@ class BasicCheckResult(Tuploid):
self.perfdata = []
for entry in perfdata:
- assert type(entry) == tuple
- self.perfdata.append(PerfValue(*entry))
+ assert type(entry) in [tuple, PerfValue]
+ if type(entry) is tuple:
+ self.perfdata.append(PerfValue(*entry))
+ else:
+ self.perfdata.append(entry)
else:
self.perfdata = None
@@ -80,6 +87,9 @@ class BasicCheckResult(Tuploid):
def tuple(self):
return (self.status, self.infotext, self.perfdata)
+ def __repr__(self):
+ return 'BasicCheckResult(%s, "%s", %s)' % (self.status,
self.infotext, self.perfdata)
+
class CheckResult(object):
"""