示例#1
0
def test_loopcheck():
    ''' test loopback checking '''
    bkt = Bucket()

    ta = Task()

    bkt.add(ta, [ta])
    assert bkt.find_loop()
    bkt.clear()

    tb = Task()
    bkt.add(ta, [tb])
    bkt.add(tb, [ta])
    assert bkt.find_loop()
    bkt.clear()

    tc = Task()
    bkt.add(ta, [tb, tc])
    bkt.add(tc, [ta])
    assert bkt.find_loop()
    bkt.clear()

    bkt.add(ta, [tb])
    bkt.add(tb, [tc])
    bkt.add(tc, [ta])
    assert bkt.find_loop()
示例#2
0
def test_add():
    ''' test add method '''
    bkt = Bucket()

    ta = Task()
    tb = Task()
    tc = Task()

    bkt.add(ta, [tb])
    bkt.add(tb, [tc])
    bkt.add(tc)  # unnecessary but ok
示例#3
0
def file(filename: str):
    ''' run a task file '''
    try:
        tsk = Task.loadFromFile(filename)
        return tsk.run()
    except Exception as ex:  # pylint: disable=broad-except
        print(ex)
示例#4
0
def test_leaf_tasks():
    ''' test find_leaf_tasks() '''
    bkt = Bucket()

    ta = Task()
    bkt.add(ta)
    assert bkt.find_leaf_tasks() == [ta]

    bkt.clear()
    tb = Task()
    bkt.add(tb, [ta])
    assert bkt.find_leaf_tasks() == [ta]

    bkt.clear()
    bkt.add(ta, [ta])
    assert bkt.find_leaf_tasks() == []
示例#5
0
def test_hello_from_json():
    ''' test json serialize of task '''
    tsk = Task.from_json("""
        {
            "_CLSID_": "Hello",
            "who": "Randy"
        }""")
    assert tsk.who == "Randy"
    tsk.run()
示例#6
0
def test_add():
    ''' test add task '''
    jstr = '{ "_CLSID_": "add", "a": 1, "b": 2 }'
    task = Task.from_json(jstr)

    assert isinstance(task, Task)
    assert type(task).__name__ == 'add'

    task.run()

    assert task.result == 1 + 2
示例#7
0
def test_task_create():
    tsk = Task()
    assert tsk.status == Task.Status.INIT