Exemple #1
0
    def test_load_process_list_yaml_error(self, mock_file, mock_load,
                                          mock_set_process_list):

        mock_load.side_effect = yaml.YAMLError

        obj = processmonitor_manager.ProcessmonitorManager()
        obj.main()

        mock_set_process_list.assert_not_called()
Exemple #2
0
    def test_load_process_list_exception(self, mock_file, mock_load,
                                         mock_set_process_list):

        mock_load.side_effect = Exception("Test exception.")

        obj = processmonitor_manager.ProcessmonitorManager()
        obj.main()

        mock_set_process_list.assert_not_called()
Exemple #3
0
    def test_main_exception(self, mock_file, mock_load, mock_set_process_list,
                            mock_start_processes, mock_monitor_processes,
                            mock_restart_processes):

        mock_load.return_value = self._get_mock_process_list(0)
        mock_set_process_list.return_value = None
        mock_start_processes.side_effect = Exception("Test exception.")

        obj = processmonitor_manager.ProcessmonitorManager()
        obj.main()

        mock_set_process_list.assert_called_once_with(MOCK_PROCESS_LIST)
        mock_start_processes.assert_called_once_with()
        mock_monitor_processes.assert_not_called()
        mock_restart_processes.assert_not_called()
Exemple #4
0
    def test_main(self, mock_file, mock_load, mock_set_process_list,
                  mock_start_processes, mock_monitor_processes,
                  mock_restart_processes, mock_sleep):

        mock_load.side_effect = [
            self._get_mock_process_list(0),
            self._get_mock_process_list(0),
            self._get_mock_process_list(1)
        ]
        mock_set_process_list.return_value = None
        mock_start_processes.return_value = None
        mock_monitor_processes.side_effect = [MOCK_DOWN_PROCESS_LIST, []]
        mock_restart_processes.return_value = None
        mock_sleep.return_value = None

        obj = processmonitor_manager.ProcessmonitorManager()
        obj.main()

        mock_set_process_list.assert_called_with(MOCK_PROCESS_LIST)
        mock_start_processes.assert_called_once_with()
        self.assertEqual(2, mock_monitor_processes.call_count)
        mock_restart_processes.assert_called_once_with(MOCK_DOWN_PROCESS_LIST)
Exemple #5
0
    def test_stop(self):

        obj = processmonitor_manager.ProcessmonitorManager()
        obj.stop()

        self.assertFalse(obj.running)