Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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')
Exemplo n.º 6
0
 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')
Exemplo n.º 7
0
 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')
Exemplo n.º 8
0
 def test_print_help(self):
     with self.assertRaises(SystemExit), mock.patch('sys.stdout'):
         main(['-h'])
Exemplo n.º 9
0
 def test_unknown_command(self):
     with self.assertRaises(SystemExit), mock.patch('sys.stderr'):
         main(['test'])
Exemplo n.º 10
0
 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')
Exemplo n.º 11
0
 def test_print_help(self):
     with self.assertRaises(SystemExit), mock.patch('sys.stdout'):
         main(['-h'])
Exemplo n.º 12
0
 def test_unknown_command(self):
     with self.assertRaises(SystemExit), mock.patch('sys.stderr'):
         main(['test'])