예제 #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()