def test_clean(self): with mock.patch('nagios2mantis.clean') as clean_mock: main(['clean']) self.assertTrue(clean_mock.called) self.assertEquals(clean_mock.call_args[0][0].configuration_file, '/etc/nagios2mantis.ini') self.assertEquals(clean_mock.call_args[0][0].func, clean_mock)
def test_empty(self): with mock.patch('nagios2mantis.empty') as empty_mock: main(['empty']) self.assertTrue(empty_mock.called) self.assertEquals(empty_mock.call_args[0][0].configuration_file, '/etc/nagios2mantis.ini') self.assertEquals(empty_mock.call_args[0][0].func, empty_mock)
def test_spool_no_service(self): args = [ '--configuration-file', '/tmp/test.ini', 'spool', '--hostname', 'localhost', '--plugin-output', 'OK', '--state', 'UP', '--host-notes', 'test' ] with mock.patch('nagios2mantis.spool') as spool_mock: main(args) self.assertEquals(spool_mock.call_args[0][0].configuration_file, '/tmp/test.ini') self.assertEquals(spool_mock.call_args[0][0].func, spool_mock) self.assertEquals(spool_mock.call_args[0][0].hostname, 'localhost') self.assertEquals(spool_mock.call_args[0][0].state, 'UP') self.assertIsNone(spool_mock.call_args[0][0].service) self.assertEquals(spool_mock.call_args[0][0].plugin_output, 'OK') self.assertEquals(spool_mock.call_args[0][0].host_notes, 'test')
def test_spool_no_service(self): args = ['--configuration-file', '/tmp/test.ini', 'spool', '--hostname', 'localhost', '--plugin-output', 'OK', '--state', 'UP', '--host-notes', 'test'] with mock.patch('nagios2mantis.spool') as spool_mock: main(args) self.assertEquals(spool_mock.call_args[0][0].configuration_file, '/tmp/test.ini') self.assertEquals(spool_mock.call_args[0][0].func, spool_mock) self.assertEquals(spool_mock.call_args[0][0].hostname, 'localhost') self.assertEquals(spool_mock.call_args[0][0].state, 'UP') self.assertIsNone(spool_mock.call_args[0][0].service) self.assertEquals(spool_mock.call_args[0][0].plugin_output, 'OK') self.assertEquals(spool_mock.call_args[0][0].host_notes, 'test')
def test_empty_conffile(self): with mock.patch('nagios2mantis.empty') as empty_mock: main(['--configuration-file', '/tmp/test.ini', 'empty']) self.assertTrue(empty_mock.called) self.assertEquals(empty_mock.call_args[0][0].configuration_file, '/tmp/test.ini')
def test_print_help(self): with self.assertRaises(SystemExit), mock.patch('sys.stdout'): main(['-h'])
def test_unknown_command(self): with self.assertRaises(SystemExit), mock.patch('sys.stderr'): main(['test'])