Пример #1
0
def test_remove_task_from_many(router: ZeebeTaskRouter, task: Task):
    router.tasks.append(task)

    for _ in range(1, randint(0, 100)):

        @router.task(str(uuid4()))
        def dummy_function():
            pass

    router.remove_task(task.type)

    assert task not in router.tasks
Пример #2
0
def test_get_task_and_index(router: ZeebeTaskRouter, task: Task):
    router.tasks.append(task)

    found_task, index = router._get_task_and_index(task.type)

    assert router.tasks[index] == task
    assert found_task == task
Пример #3
0
def test_add_before_decorator_through_constructor(decorator: TaskDecorator):
    router = ZeebeTaskRouter(before=[decorator])

    assert len(router._before) == 1
Пример #4
0
def test_add_after_decorator(router: ZeebeTaskRouter,
                             decorator: TaskDecorator):
    router.after(decorator)

    assert len(router._after) == 1
Пример #5
0
def test_add_before_decorator(router: ZeebeTaskRouter,
                              decorator: TaskDecorator):
    router.before(decorator)

    assert len(router._before) == 1
Пример #6
0
def test_no_duplicate_task_type_error_is_raised(router: ZeebeTaskRouter,
                                                task: Task):
    router._is_task_duplicate(task.type)
Пример #7
0
def test_check_is_task_duplicate_with_duplicate(router: ZeebeTaskRouter,
                                                task: Task):
    router.tasks.append(task)
    with pytest.raises(DuplicateTaskTypeError):
        router._is_task_duplicate(task.type)
Пример #8
0
def test_remove_fake_task(router: ZeebeTaskRouter):
    with pytest.raises(TaskNotFoundError):
        router.remove_task(str(uuid4()))
Пример #9
0
def test_remove_task(router: ZeebeTaskRouter, task: Task):
    router.tasks.append(task)

    router.remove_task(task.type)

    assert task not in router.tasks
Пример #10
0
def test_get_task_index(router: ZeebeTaskRouter, task: Task):
    router.tasks.append(task)

    index = router._get_task_index(task.type)

    assert router.tasks[index] == task
Пример #11
0
def test_get_task(router: ZeebeTaskRouter, task: Task):
    router.tasks.append(task)

    found_task = router.get_task(task.type)

    assert found_task == task
Пример #12
0
def test_add_after_decorator_through_constructor(decorator: TaskDecorator):
    router = ZeebeTaskRouter(after=[decorator])

    assert len(router._after) == 1
Пример #13
0
def routers():
    return [ZeebeTaskRouter() for _ in range(0, randint(2, 100))]
Пример #14
0
def router():
    return ZeebeTaskRouter()