def test_no_previous_execution(self, mock_run): datawatch.get_all_registered_checks = mock.MagicMock(return_value=[ CheckRunEvery]) scheduler = Scheduler() scheduler.get_last_executions = mock.MagicMock(return_value={}) scheduler.run_checks() self.assertTrue(mock_run.called)
def test_skip_no_run_every(self, mock_run): datawatch.get_all_registered_checks = mock.MagicMock(return_value=[ CheckNoRunEvery]) scheduler = Scheduler() scheduler.get_last_executions = mock.MagicMock(return_value={}) scheduler.run_checks() self.assertFalse(mock_run.called)
def test_execution_in_future_and_force(self, mock_run): datawatch.get_all_registered_checks = mock.MagicMock(return_value=[ CheckRunEvery]) scheduler = Scheduler() scheduler.get_last_executions = mock.MagicMock(return_value={ 'django_datawatch.tests.test_scheduler.CheckRunEvery': datetime.datetime(2016, 12, 1, 0, 0, 0, 0, pytz.timezone( settings.TIME_ZONE)), }) scheduler.run_checks(force=True) self.assertTrue(mock_run.called)
def django_datawatch_scheduler(*args, **kwargs): Scheduler().run_checks(force=False)
def handle(self, force, slug, *args, **options): Scheduler().run_checks(force=force, slug=slug)
def run(self, *args, **kwargs): Scheduler().run_checks(force=False)