Example #1
0
    def test_reload(self):
        control = daemon()
        os.system = MagicMock()
        os.system.return_value = 0

        control.reload()

        os.system.assert_called_once_with("%s reload" % self.nagios_init)
Example #2
0
    def test_status(self):
        control = daemon()
        os.system = MagicMock()
        os.system.return_value = 0

        control.status()

        os.system.assert_called_once_with("%s status" % self.nagios_init)
Example #3
0
 def test_verify_config_success(self):
     control = daemon()
     os.system = MagicMock()
     os.system.return_value = 0
     
     result = control.verify_config()
     self.assertTrue(result)
     os.system.assert_called_once_with("%s -v %s" % (self.nagios_bin, self.nagios_cfg))
Example #4
0
 def test_verify_config_failure(self):
     control = daemon()
     os.system = MagicMock()
     os.system.return_value = 1
     
     result = control.verify_config()
     self.assertEqual(result, None)
     os.system.assert_called_once_with("%s -v %s" % (self.nagios_bin, self.nagios_cfg))
Example #5
0
 def _reload(self):
     logging.warn(
         "[audit] [user: %s] triggered the reload command" %
         (request.authorization.username), )
     daemon.systemd_service_path = config['systemd_service_path']
     d = daemon(service_name=config['service_name'])
     d.reload()
     return {'result': 'successfully reload Nagios'}