def test_main(self, mock_service, mock_thread, spare_amp_thread_event_mock, db_cleanup_thread_event_mock, cert_rotate_thread_event_mock): spare_amp_thread_mock = mock.MagicMock() db_cleanup_thread_mock = mock.MagicMock() cert_rotate_thread_mock = mock.MagicMock() mock_thread.side_effect = [ spare_amp_thread_mock, db_cleanup_thread_mock, cert_rotate_thread_mock ] spare_amp_thread_mock.daemon.return_value = True db_cleanup_thread_mock.daemon.return_value = True cert_rotate_thread_mock.daemon.return_value = True house_keeping.main() spare_amp_thread_mock.start.assert_called_once_with() db_cleanup_thread_mock.start.assert_called_once_with() cert_rotate_thread_mock.start.assert_called_once_with() self.assertTrue(spare_amp_thread_mock.daemon) self.assertTrue(db_cleanup_thread_mock.daemon) self.assertTrue(cert_rotate_thread_mock.daemon)
def test_main_keyboard_interrupt(self, mock_service, mock_thread, db_cleanup_thread_event_mock, cert_rotate_thread_event_mock): db_cleanup_thread_mock = mock.MagicMock() cert_rotate_thread_mock = mock.MagicMock() mock_thread.side_effect = [db_cleanup_thread_mock, cert_rotate_thread_mock] db_cleanup_thread_mock.daemon.return_value = True cert_rotate_thread_mock.daemon.return_value = True mock_join = mock.MagicMock() mock_join.side_effect = [KeyboardInterrupt, None] db_cleanup_thread_mock.join = mock_join house_keeping.main() db_cleanup_thread_event_mock.set.assert_called_once_with() cert_rotate_thread_event_mock.set.assert_called_once_with() db_cleanup_thread_mock.start.assert_called_once_with() cert_rotate_thread_mock.start.assert_called_once_with() self.assertTrue(db_cleanup_thread_mock.daemon) self.assertTrue(cert_rotate_thread_mock.daemon) self.assertEqual(2, db_cleanup_thread_mock.join.call_count) cert_rotate_thread_mock.join.assert_called_once_with()
def test_main_keyboard_interrupt(self, mock_service, mock_thread, spare_amp_thread_event_mock, db_cleanup_thread_event_mock, cert_rotate_thread_event_mock, sleep_time): spare_amp_thread_mock = mock.MagicMock() db_cleanup_thread_mock = mock.MagicMock() cert_rotate_thread_mock = mock.MagicMock() mock_thread.side_effect = [ spare_amp_thread_mock, db_cleanup_thread_mock, cert_rotate_thread_mock ] spare_amp_thread_mock.daemon.return_value = True db_cleanup_thread_mock.daemon.return_value = True cert_rotate_thread_mock.daemon.return_value = True # mock the time.sleep() in the while loop sleep_time.side_effect = [True, KeyboardInterrupt] house_keeping.main() spare_amp_thread_event_mock.set.assert_called_once_with() spare_amp_thread_event_mock.clear.assert_called_once_with() db_cleanup_thread_event_mock.set.assert_called_once_with() db_cleanup_thread_event_mock.clear.assert_called_once_with() cert_rotate_thread_event_mock.set.assert_called_once_with() cert_rotate_thread_event_mock.clear.assert_called_once_with() spare_amp_thread_mock.start.assert_called_once_with() db_cleanup_thread_mock.start.assert_called_once_with() cert_rotate_thread_mock.start.assert_called_once_with() self.assertTrue(spare_amp_thread_mock.daemon) self.assertTrue(db_cleanup_thread_mock.daemon) self.assertTrue(cert_rotate_thread_mock.daemon) spare_amp_thread_mock.join.assert_called_once_with() db_cleanup_thread_mock.join.assert_called_once_with() cert_rotate_thread_mock.join.assert_called_once_with()
def test_main_keyboard_interrupt(self, mock_service, mock_thread, spare_amp_thread_event_mock, db_cleanup_thread_event_mock, cert_rotate_thread_event_mock, sleep_time): spare_amp_thread_mock = mock.MagicMock() db_cleanup_thread_mock = mock.MagicMock() cert_rotate_thread_mock = mock.MagicMock() mock_thread.side_effect = [spare_amp_thread_mock, db_cleanup_thread_mock, cert_rotate_thread_mock] spare_amp_thread_mock.daemon.return_value = True db_cleanup_thread_mock.daemon.return_value = True cert_rotate_thread_mock.daemon.return_value = True # mock the time.sleep() in the while loop sleep_time.side_effect = [True, KeyboardInterrupt] house_keeping.main() spare_amp_thread_event_mock.set.assert_called_once_with() spare_amp_thread_event_mock.clear.assert_called_once_with() db_cleanup_thread_event_mock.set.assert_called_once_with() db_cleanup_thread_event_mock.clear.assert_called_once_with() cert_rotate_thread_event_mock.set.assert_called_once_with() cert_rotate_thread_event_mock.clear.assert_called_once_with() spare_amp_thread_mock.start.assert_called_once_with() db_cleanup_thread_mock.start.assert_called_once_with() cert_rotate_thread_mock.start.assert_called_once_with() self.assertTrue(spare_amp_thread_mock.daemon) self.assertTrue(db_cleanup_thread_mock.daemon) self.assertTrue(cert_rotate_thread_mock.daemon) spare_amp_thread_mock.join.assert_called_once_with() db_cleanup_thread_mock.join.assert_called_once_with() cert_rotate_thread_mock.join.assert_called_once_with()