File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 - name : Lint
1919 run : |
2020 make lint
21+ - name : Test
22+ run : |
23+ make coverage
Original file line number Diff line number Diff line change 1- .PHONY : lint
1+ .PHONY : lint test coverage
22
33lint :
44 python -m pylint check_sensorProbe2plus.py
5+ test :
6+ python -m unittest -v test_check_sensorProbe2plus.py
7+ coverage :
8+ python -m coverage run -m unittest -b test_check_sensorProbe2plus.py
9+ python -m coverage report -m --include check_sensorProbe2plus.py
Original file line number Diff line number Diff line change 11pylint == 3.3.7
2+ coverage == 7.9.0
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+
3+ import unittest
4+ import unittest .mock as mock
5+ import sys
6+
7+ sys .path .append ('..' )
8+
9+ from check_sensorProbe2plus import convert_state_to_nagios
10+ from check_sensorProbe2plus import print_status_message
11+
12+ from check_sensorProbe2plus import NagiosState
13+
14+ class UtilTesting (unittest .TestCase ):
15+
16+ def test_state (self ):
17+ actual = convert_state_to_nagios (1 )
18+ expected = NagiosState .UNKNOWN
19+
20+ self .assertEqual (actual , expected )
21+
22+ @mock .patch ('builtins.print' )
23+ def test_status_message (self , mock_print ):
24+ sensor_states = {
25+ "OK" : [],
26+ "WARNING" : [],
27+ "CRITICAL" : [],
28+ "UNKNOWN" : [],
29+ }
30+
31+ print_status_message (sensor_states , "perfdata" )
32+
33+ calls = [mock .call ('OK sensorProbe2plus: Sensor reports that everything is fine|p e r f d a t a ' )]
34+
35+ mock_print .assert_has_calls (calls )
36+
You can’t perform that action at this time.
0 commit comments