def test_add_incoming_input_work(self): """Nodes can have an infinite amount of incoming INPUT_WORK links, as long as the link pair is unique.""" source_one = Data() source_two = Data() target = WorkflowNode() target.add_incoming(source_one, LinkType.INPUT_WORK, 'link_label') # Can only have a single incoming INPUT_WORK link from each source node if the label is not unique with self.assertRaises(ValueError): target.validate_incoming(source_one, LinkType.INPUT_WORK, 'link_label') # Using another link label is fine target.validate_incoming(source_one, LinkType.INPUT_WORK, 'other_label') # However, using the same link, even from another node is illegal with self.assertRaises(ValueError): target.validate_incoming(source_two, LinkType.INPUT_WORK, 'link_label')
def test_add_incoming_call_work(self): """Nodes can only have a single incoming CALL_WORK link, independent of the source node.""" source_one = WorkflowNode() source_two = WorkflowNode() target = WorkflowNode() target.add_incoming(source_one, LinkType.CALL_WORK, 'link_label') # Can only have a single incoming CALL_WORK link with self.assertRaises(ValueError): target.validate_incoming(source_one, LinkType.CALL_WORK, 'link_label') # Even when the source node is different with self.assertRaises(ValueError): target.validate_incoming(source_two, LinkType.CALL_WORK, 'link_label') # Or when the link label is different with self.assertRaises(ValueError): target.validate_incoming(source_one, LinkType.CALL_WORK, 'other_label')