def test_willUpdateFilesEveryLoopIteration(self, mock_updater, mock_observer_obj, mock_sleep): self.mock_running.side_effect = [True, True, True, False] patient = ProjectWatcher('project_path', mock_updater) patient.start() self.assertEqual(mock_updater.update_files.call_count, 3)
def test_willStartObserverOnStart(self, mock_updater, mock_observer_obj, mock_sleep): mock_observer = mock_observer_obj.return_value patient = ProjectWatcher('project_path', mock_updater) patient.start() mock_observer.start.assert_called_once_with()
def test_willStopAndJoinObserverOnStop(self, mock_updater, mock_observer_obj): mock_observer = mock_observer_obj.return_value patient = ProjectWatcher('project_path', mock_updater) patient.stop() mock_observer.stop.assert_called_once_with() mock_observer.join.assert_called_once_with()
def test_willQuitLoopOnKeyboardInterrupt(self, mock_updater, mock_observer_obj, mock_sleep): def raise_keyboard_interrupt(*args, **kwargs): raise KeyboardInterrupt() self.mock_running.side_effect = None mock_sleep.side_effect = raise_keyboard_interrupt patient = ProjectWatcher('project_path', mock_updater) patient.start() mock_sleep.assert_called_once_with(1)
def test_willSleepForOneSecondOnStart(self, mock_updater, mock_observer_obj, mock_sleep): patient = ProjectWatcher('project_path', mock_updater) patient.start() mock_sleep.assert_called_once_with(1)