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()
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()
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
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__")
def test_invalid_transition(): task = Task('key') task.transition('complete')
def test_invalid_state(): task = Task("key") task.state = "invalid" for t in task: t()
def test_kwargs(): task = Task("key", foo="bar", abc="def") assert task.args['foo'] == 'bar' assert task.args['abc'] == 'def'