mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2026-02-05 22:55:15 +01:00
Add unittest for debugprint
This commit is contained in:
26
test/test_main.py
Normal file
26
test/test_main.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import unittest.mock as mock
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append('..')
|
||||||
|
|
||||||
|
from check_http_json import debugPrint
|
||||||
|
|
||||||
|
|
||||||
|
class MainTest(unittest.TestCase):
|
||||||
|
"""
|
||||||
|
Tests for main
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_debugprint(self):
|
||||||
|
with mock.patch('builtins.print') as mock_print:
|
||||||
|
debugPrint(True, 'debug')
|
||||||
|
mock_print.assert_called_once_with('debug')
|
||||||
|
|
||||||
|
def test_debugprint_pprint(self):
|
||||||
|
with mock.patch('check_http_json.pprint') as mock_pprint:
|
||||||
|
debugPrint(True, 'debug', True)
|
||||||
|
mock_pprint.assert_called_once_with('debug')
|
||||||
Reference in New Issue
Block a user