|
10 | 10 |
|
11 | 11 | sys.path.append('..') |
12 | 12 |
|
| 13 | +from check_vmware_nsxt import main |
| 14 | +from check_vmware_nsxt import fix_tls_cert_store |
13 | 15 | from check_vmware_nsxt import commandline |
14 | 16 | from check_vmware_nsxt import worst_state |
15 | 17 | from check_vmware_nsxt import time_iso |
|
19 | 21 |
|
20 | 22 | os.environ["TZ"] = "UTC" |
21 | 23 |
|
| 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 | + |
22 | 34 | class CLITesting(unittest.TestCase): |
23 | 35 |
|
24 | 36 | def test_commandline(self): |
@@ -62,6 +74,20 @@ def test_time_iso(self): |
62 | 74 | expected = datetime.datetime(1970, 1, 20, 11, 46, 28, 760000) |
63 | 75 | self.assertEqual(actual, expected) |
64 | 76 |
|
| 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 | + |
65 | 91 | class ClientTesting(unittest.TestCase): |
66 | 92 |
|
67 | 93 | @mock.patch('requests.request') |
|
0 commit comments