forked from hobbsh/check-idrac-sensor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
31 lines (28 loc) · 965 Bytes
/
test.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
import pytest
import check_idrac_sensor as cis
import re
@pytest.fixture()
def load_status():
ret = []
with open('tests/drac_fake_status','r') as dfs:
ret = dfs.readlines()
dfs.closed
return ret
@pytest.fixture()
def run_lines_to_dict(load_status):
val = cis.lines_to_dict(load_status)
return val
def test_lines_to_dict(load_status):
val = cis.lines_to_dict(load_status)
assert len(val) == 12
def test_nagios_output(run_lines_to_dict):
sensors = ['redundancy', 'temperature', 'power', 'battery', 'system_performance', 'current', 'fan', 'voltage', 'memory', 'performance', 'intrusion', 'processor']
val = cis.nagios_output(run_lines_to_dict, 'all')
assert len(val) == 2081
assert re.findall('Warning', val)
for sensor in sensors:
val = cis.nagios_output(run_lines_to_dict, sensor)
if sensor == 'memory':
assert re.findall('Warning', val)
else:
assert val