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()
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
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)
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() == []
def test_hello_from_json(): ''' test json serialize of task ''' tsk = Task.from_json(""" { "_CLSID_": "Hello", "who": "Randy" }""") assert tsk.who == "Randy" tsk.run()
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
def test_task_create(): tsk = Task() assert tsk.status == Task.Status.INIT