-
Notifications
You must be signed in to change notification settings - Fork 5
/
mock.py
50 lines (37 loc) · 1.33 KB
/
mock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
class CollectdMock(object):
def __init__(self, plugin):
self.value_mock = CollectdValuesMock
self.notification_mock = CollectdNotificationMock
self.plugin = plugin
def info(self, msg):
print 'INFO: %s' % (msg)
def warning(self, msg):
print 'WARN: %s' % (msg)
def error(self, msg):
print 'ERROR: %s' % (msg)
sys.exit(1)
def debug(self, msg):
print 'DEBUG: %s' % (msg)
def Values(self, plugin=None, plugin_instance=None, type=None, type_instance=None, values=None):
return (self.value_mock)()
def Notification(self, plugin=None, plugin_instance=None, type=None, type_instance=None, severity=None, message=None):
return (self.notification_mock)()
class CollectdValuesMock(object):
def dispatch(self):
print self
def __str__(self):
attrs = []
for name in dir(self):
if not name.startswith('_') and name is not 'dispatch':
attrs.append("%s=%s" % (name, getattr(self, name)))
return "<CollectdValues %s>" % (' '.join(attrs))
class CollectdNotificationMock(object):
def dispatch(self):
print self
def __str__(self):
attrs = []
for name in dir(self):
if not name.startswith('_') and name is not 'dispatch':
attrs.append("%s=%s" % (name, getattr(self, name)))
return "<CollectdNotification %s>" % (' '.join(attrs))