示例#1
0
    def test_main(self, mock_service, mock_process):
        mock_listener_proc = mock.MagicMock()
        mock_health_proc = mock.MagicMock()

        mock_process.side_effect = [mock_listener_proc, mock_health_proc]

        health_manager.main()

        mock_listener_proc.start.assert_called_once_with()
        mock_health_proc.start.assert_called_once_with()
        mock_listener_proc.join.assert_called_once_with()
        mock_health_proc.join.assert_called_once_with()
示例#2
0
    def test_main_keyboard_interrupt(self, mock_service, mock_process):
        mock_listener_proc = mock.MagicMock()
        mock_health_proc = mock.MagicMock()
        mock_join = mock.MagicMock()
        mock_join.side_effect = KeyboardInterrupt
        mock_listener_proc.join = mock_join

        mock_process.side_effect = [mock_listener_proc, mock_health_proc]

        health_manager.main()

        mock_listener_proc.start.assert_called_once_with()
        mock_health_proc.start.assert_called_once_with()
        mock_listener_proc.join.assert_called_once_with()
        self.assertFalse(mock_health_proc.join.called)
示例#3
0
    def test_main_keyboard_interrupt(self, mock_service, mock_process,
                                     mock_kill):
        mock_listener_proc = mock.MagicMock()
        mock_health_proc = mock.MagicMock()
        mock_join = mock.MagicMock()
        mock_join.side_effect = [KeyboardInterrupt, None]
        mock_listener_proc.join = mock_join

        mock_process.side_effect = [mock_listener_proc, mock_health_proc]

        health_manager.main()

        mock_listener_proc.start.assert_called_once_with()
        mock_health_proc.start.assert_called_once_with()
        self.assertEqual(2, mock_listener_proc.join.call_count)
        mock_health_proc.join.assert_called_once_with()
        mock_kill.assert_called_once_with(mock_health_proc.pid, signal.SIGINT)
示例#4
0
    def test_main_keyboard_interrupt(self, mock_service, mock_process,
                                     mock_kill):
        mock_listener_proc = mock.MagicMock()
        mock_health_proc = mock.MagicMock()
        mock_join = mock.MagicMock()
        mock_join.side_effect = [KeyboardInterrupt, None]
        mock_listener_proc.join = mock_join

        mock_process.side_effect = [mock_listener_proc, mock_health_proc]

        health_manager.main()

        mock_listener_proc.start.assert_called_once_with()
        mock_health_proc.start.assert_called_once_with()
        self.assertEqual(2, mock_listener_proc.join.call_count)
        mock_health_proc.join.assert_called_once_with()
        mock_kill.assert_called_once_with(mock_health_proc.pid,
                                          signal.SIGINT)