Ejemplo n.º 1
0
def test_tasks_get_by_unknown_or_wrong_object():
    tasks = Tasks()
    with pytest.raises(exc.UnknownTask):
        tasks.get('foo')
    with pytest.raises(exc.UnknownTask):
        tasks.get(None)
    with pytest.raises(exc.UnknownTask):
        tasks.get(object())
    with pytest.raises(exc.UnknownTask):
        tasks.get(b'foo')
    with pytest.raises(exc.UnknownTask):
        tasks.get(RuntimeError)
Ejemplo n.º 2
0
def test_tasks_get_by_task_object(task):
    tasks = Tasks()
    tasks._tasks[task.name] = task

    r = tasks.get(task)
    assert isinstance(r, Task)
    assert r.name == task.name
    assert r.func == task.func
Ejemplo n.º 3
0
def test_tasks_get_by_name():
    tasks = Tasks()
    tasks.add(print, 'foo')

    r = tasks.get('foo')
    assert isinstance(r, Task)
    assert r.name == 'foo'
    assert r.func == print
Ejemplo n.º 4
0
def test_tasks_get_by_function():
    tasks = Tasks()

    @tasks.task(name='foo')
    def foo():
        pass

    r = tasks.get(foo)
    assert isinstance(r, Task)
    assert r.name == 'foo'
    assert r.func == foo