-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_nagios_test.py
36 lines (27 loc) · 1014 Bytes
/
run_nagios_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
32
33
34
35
36
#!/usr/bin/python
from __future__ import division
import glob
import pep8
import sys
import unittest
from run_nagios import run_check
class RunCheckTestCase(unittest.TestCase):
def testOK(self):
result = run_check(['/bin/sh', '-c', '/bin/echo TRUE; /bin/true'])
self.assertEqual(result, (0, b'TRUE'))
def testWARNING(self):
result = run_check(['/bin/sh', '-c', '/bin/echo FALSE; /bin/false'])
self.assertEqual(result, (1, b'FALSE'))
class CodeFormatTestCase(unittest.TestCase):
def test_pep8_conformance(self):
"""Test that we conform to PEP8."""
pep8style = pep8.StyleGuide(quiet=True)
files = []
files += glob.glob('*.py')
files += glob.glob('*/*.py')
files += ['run-nagios-passive-check-and-submit']
result = pep8style.check_files(files)
self.assertEqual(result.total_errors, 0,
'Found code style errors (and warnings).')
if __name__ == '__main__':
unittest.main()