Ejemplo n.º 1
0
    def test_add_executor(self, scheduler, stopped):
        scheduler._stopped = stopped
        executor = DebugExecutor()
        executor.start = MagicMock()
        scheduler.add_executor(executor)

        assert scheduler._executors == {"default": executor}
        if not stopped:
            executor.start.assert_called_once_with(scheduler, "default")
        else:
            assert executor.start.call_count == 0
Ejemplo n.º 2
0
    def test_add_executor(self, scheduler, stopped):
        scheduler._stopped = stopped
        executor = DebugExecutor()
        executor.start = MagicMock()
        scheduler.add_executor(executor)

        assert scheduler._executors == {'default': executor}
        if not stopped:
            executor.start.assert_called_once_with(scheduler, 'default')
        else:
            assert executor.start.call_count == 0
Ejemplo n.º 3
0
 def test_add_executor_already_exists(self, scheduler):
     executor = DebugExecutor()
     scheduler.add_executor(executor)
     exc = pytest.raises(ValueError, scheduler.add_executor, executor)
     assert str(
         exc.value
     ) == 'This scheduler already has an executor by the alias of "default"'
Ejemplo n.º 4
0
    def test_remove_executor(self, scheduler):
        scheduler.add_executor(DebugExecutor(), 'foo')
        scheduler._dispatch_event = MagicMock()
        scheduler.remove_executor('foo')

        assert scheduler._executors == {}
        assert scheduler._dispatch_event.call_count == 1
        event = scheduler._dispatch_event.call_args[0][0]
        assert event.code == EVENT_EXECUTOR_REMOVED
        assert event.alias == 'foo'
Ejemplo n.º 5
0
def scheduler(jobstore, settings):
    scheduler = DummyScheduler(timezone=settings.TIME_ZONE)
    scheduler.add_jobstore(jobstore, "default")
    scheduler.add_executor(DebugExecutor())

    return scheduler
Ejemplo n.º 6
0
 def executor(self, scheduler):
     scheduler.add_executor(DebugExecutor())
Ejemplo n.º 7
0
def scheduler():
    scheduler = DebugScheduler(timezone=pytz.timezone("Europe/Moscow"))
    scheduler.add_jobstore(DjangoJobStore())
    scheduler.add_executor(DebugExecutor())

    return scheduler
def scheduler():
    scheduler = DebugScheduler()
    scheduler.add_jobstore(DjangoJobStore())
    scheduler.add_executor(DebugExecutor())

    return scheduler