Esempio n. 1
0
def test_set_log():
    task = Task("key")
    assert not hasattr(task, 'log')
    task.set_log()
    assert hasattr(task, 'log')
    assert hasattr(task, 'logstream')
    task.log.debug("please write me to log")
    assert "please write me to log" in task.logstream.getvalue()
Esempio n. 2
0
def test_set_log():
    task = Task("key")
    assert not hasattr(task, 'log')
    task.set_log()
    assert hasattr(task, 'log')
    assert hasattr(task, 'logstream')
    task.log.debug("please write me to log")
    assert "please write me to log" in task.logstream.getvalue()
Esempio n. 3
0
def test_circular_4_docs():
    runner = Runner()
    d1 = Task("1", runner=runner)
    d2 = Task("2", runner=runner)
    d3 = Task("3", runner=runner)
    d4 = Task("4", runner=runner)

    d1.children.append(d2)
    d2.children.append(d3)
    d3.children.append(d4)
    d4.children.append(d1)

    for t in d1:
        t()
Esempio n. 4
0
def test_circular():
    runner = Runner()
    d1 = Task("1",runner=runner)
    d2 = Task("2",runner=runner)

    d1.children.append(d2)
    d2.children.append(d1)

    try:
        for t in d1:
            t()
        assert False
    except CircularDependency:
        assert True
Esempio n. 5
0
def test_init():
    task = Task("key")
    assert isinstance(task.args, dict)
    assert isinstance(task.children, list)
    assert task.key == "key"

    assert hasattr(task, 'pre')
    assert hasattr(task, 'post')
    assert hasattr(task.pre, "__call__")
    assert hasattr(task.post, "__call__")
Esempio n. 6
0
def test_invalid_transition():
    task = Task('key')
    task.transition('complete')
Esempio n. 7
0
def test_invalid_state():
    task = Task("key")
    task.state = "invalid"
    for t in task:
        t()
Esempio n. 8
0
def test_invalid_transition():
    task = Task('key')
    task.transition('complete')
Esempio n. 9
0
def test_invalid_state():
    task = Task("key")
    task.state = "invalid"
    for t in task:
        t()
Esempio n. 10
0
def test_kwargs():
    task = Task("key", foo="bar", abc="def")
    assert task.args['foo'] == 'bar'
    assert task.args['abc'] == 'def'