Exemplo n.º 1
0
    def test_registers_task_instance(self, worker: Worker):
        def func(x):
            return x

        worker.register("test", func)
        task = worker.get_registered_task("test")
        assert isinstance(task, Task)
Exemplo n.º 2
0
    def test_can_get_registered_task(self, worker: Worker):
        # This can arguably be under this set of tests
        # or the `get_registered_task` tests,
        # but it makes sure that any registered task
        # can be retrieved by name.
        def func(x):
            return x

        worker.register("test", func)
        task = worker.get_registered_task("test")

        assert task.func == func
        assert task.name == "test"
        assert task.bind == False
Exemplo n.º 3
0
    def test_can_register_with_and_without_binds(self, worker: Worker, bind: bool):
        def func(x):
            return x

        worker.register("test", func, bind=bind)
Exemplo n.º 4
0
    def test_errors_without_callable_func(self, worker: Worker):

        with pytest.raises(ValueError):
            worker.register("test", "will_cause_error", True)