def test_add_dependency(self, sig_factory): s1 = sig_factory.create() s2 = sig_factory.create() n1 = WorkflowNode(s1) n2 = WorkflowNode(s2) n1.add_dependency(n2) assert n1.dependencies assert n2.id in n1.dependencies
def test_constructor(self, sig_factory): sig = sig_factory.create() sig.freeze() node = WorkflowNode(sig) assert node.signature == sig assert node.dependencies == {} assert node.id == sig.id == 'task-1' sig.freeze.asset_called_once()
def test_add_dependency_already_added(self, sig_factory): s1 = sig_factory.create() s2 = sig_factory.create() n1 = WorkflowNode(s1) n2 = WorkflowNode(s2) n1.add_dependency(n2) with pytest.raises(WorkflowException, match='already added'): n1.add_dependency(n2)
def test_to_dict(self, sig_factory): w1 = WorkflowNode(sig_factory.create()) w2 = WorkflowNode(sig_factory.create()) w3 = WorkflowNode(sig_factory.create()) w1.add_dependency(w2) w1.add_dependency(w3) w1.custom_payload["foo"] = "bar" d = w1.to_dict() assert d['id'] == 'task-1' assert d['dependencies'] assert d['dependencies']['task-2'] is None assert d['dependencies']['task-3'] is None assert d['custom_payload']['foo'] == "bar" assert d['signature'] is w1.signature
def test_to_dict(self, sig_factory): w1 = WorkflowNode(sig_factory.create()) w2 = WorkflowNode(sig_factory.create()) w3 = WorkflowNode(sig_factory.create()) w1.add_dependency(w2) w1.add_dependency(w3) d = w1.to_dict() assert d['id'] == 'task-1' assert d['dependencies'] assert d['dependencies']['task-2'] is None assert d['dependencies']['task-3'] is None assert d['signature'] is w1.signature
def test_from_dict(self): data_dict = { 'id': 'task-7', 'signature': { 'options': { 'task_id': 'task-7' }, 'task': None, 'args': (), 'kwargs': {}, }, 'dependencies': { 'task-4': None }, } w1 = WorkflowNode.from_dict(data_dict) assert w1.id == 'task-7' assert w1.signature.id == 'task-7' assert w1.dependencies == {'task-4': None}
def test_from_dict_with_custom_payload(self): data_dict = { 'id': 'task-7', 'signature': { 'options': { 'task_id': 'task-7' }, 'task': None, 'args': (), 'kwargs': {}, }, 'dependencies': { 'task-4': None }, 'custom_payload': { 'foo': 42 } } w1 = WorkflowNode.from_dict(data_dict) assert w1.id == 'task-7' assert w1.signature.id == 'task-7' assert w1.dependencies == {'task-4': None} assert w1.custom_payload['foo'] == 42
def test_constructor_not_frozen(self, sig_factory): sig = sig_factory.create(freeze=False) with pytest.raises(WorkflowException, match='not frozen'): WorkflowNode(sig)