-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebMonitorTest.py
80 lines (61 loc) · 2.11 KB
/
WebMonitorTest.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import json
from time import strftime
from WebMonitor import WebMonitor
print('WebMonitorTest v1.0.2')
monitor = WebMonitor(pcf='test')
# Uncomment for check this
# print('-'*10, 'Add test 1 (Get Exception)')
# monitor.add()
print('-'*10, 'Add test 2 (Add as tuple)')
monitor.add('example.org', 'google.com', 'google.com', 'bing.com')
print('-'*10, 'Add test 3 (Add as list)')
monitor.add(['list.org', 'github.com', 'yandex.com', 'mail.google.com', 'github.com', 'stackoverflow.com'])
# Show added hosts to PCF
# Print to Cli in realtime
# Return list(hosts)
print('-'*10, 'Show hosts test 1')
show = monitor.show()
print(show)
# Check all hosts in added to PCF
# parameter `force_check` deprecated for all calls
print('-'*10, 'Check test 1 (Check all hosts in added to PCF)')
check = monitor.check()
print(check)
# Check as tuple
print('-'*10, 'Check test 2 (Check as tuple)')
check = monitor.check('intel.com', 'ibm.com')
print(check)
# Check as list
print('-'*10, 'Check test 3 (Check as list)')
check = monitor.check(['example.org', 'bing.com'])
print(check)
# Show history checks
print('-'*10, 'Show history checks (for all)')
history = monitor.history()
print(history)
print('-'*10, 'Show history checks test 1 (with conditions)')
history = monitor.history(by=[{'date': strftime("%Y.%m.%d")}, {'host': 'google.com'}])
print(history)
print('-'*10, 'Show history checks test 2 (with conditions)')
history = monitor.history(by=[{'host': 'bing.com'}])
print(history)
print('-'*10, 'Show history checks test 3 (with conditions)')
history = monitor.history(by=[{'id': [2]}, {'id': [1, 3]}])
print(history)
# Removing
print('-'*10, 'Removing test 1 (Remove as tuple)')
monitor.remove('example.org', 'bing.com')
print('-'*10, 'Removing test 2 (Remove as list)')
monitor.remove(['example.org', 'bing.com'])
print('-'*10, 'Show hosts (before remove all hosts)')
monitor.show()
print('-'*10, 'Removing test 3 (remove all hosts)')
monitor.remove()
print('-'*10, 'Show hosts (after remove all hosts)')
monitor.show()
# But history saved
history = monitor.history()
print(history)
# History cleared
history = monitor.history(clear=True)
print(history)