Skip to content

Commit 08f952f

Browse files
author
Markus Opolka
committed
Extend tests
1 parent 12a13ff commit 08f952f

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

test_check_vmware_nsxt.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
sys.path.append('..')
1212

13+
from check_vmware_nsxt import main
14+
from check_vmware_nsxt import fix_tls_cert_store
1315
from check_vmware_nsxt import commandline
1416
from check_vmware_nsxt import worst_state
1517
from check_vmware_nsxt import time_iso
@@ -19,6 +21,16 @@
1921

2022
os.environ["TZ"] = "UTC"
2123

24+
class MainTesting(unittest.TestCase):
25+
26+
@mock.patch('check_vmware_nsxt.Client')
27+
def test_main(self, mock_client):
28+
29+
args = commandline(['-A', 'api', '-u', 'user', '-p', 'password', '-m', 'alarms'])
30+
main(args)
31+
32+
mock_client.assert_called_with('api', 'user', 'password', verify=True, max_age=5)
33+
2234
class CLITesting(unittest.TestCase):
2335

2436
def test_commandline(self):
@@ -62,6 +74,20 @@ def test_time_iso(self):
6274
expected = datetime.datetime(1970, 1, 20, 11, 46, 28, 760000)
6375
self.assertEqual(actual, expected)
6476

77+
@mock.patch('os.stat')
78+
def test_fix_tls_cert_store(self, mock_os):
79+
80+
self.assertIsNone(fix_tls_cert_store(None))
81+
82+
m = mock.MagicMock()
83+
m.st_size = 10
84+
mock_os.return_value = m
85+
86+
fix_tls_cert_store("/tmp/foo")
87+
88+
mock_os.assert_called_with("/tmp/foo")
89+
90+
6591
class ClientTesting(unittest.TestCase):
6692

6793
@mock.patch('requests.request')

0 commit comments

Comments
 (0)