def test_validate_incoming_sealed(self): """Verify that trying to add a link to a sealed node will raise.""" data = Int(1).store() node = CalculationNode().store() node.seal() with self.assertRaises(exceptions.ModificationNotAllowed): node.validate_incoming(data, link_type=LinkType.INPUT_CALC, link_label='input')
def test_add_incoming_input_calc(self): """Nodes can have an infinite amount of incoming INPUT_CALC links, as long as the link pair is unique.""" source_one = Data() source_two = Data() target = CalculationNode() target.add_incoming(source_one, LinkType.INPUT_CALC, 'link_label') # Can only have a single incoming INPUT_CALC link from each source node if the label is not unique with self.assertRaises(ValueError): target.validate_incoming(source_one, LinkType.INPUT_CALC, 'link_label') # Using another link label is fine target.validate_incoming(source_one, LinkType.INPUT_CALC, 'other_label') # However, using the same link, even from another node is illegal with self.assertRaises(ValueError): target.validate_incoming(source_two, LinkType.INPUT_CALC, 'link_label')
def test_add_incoming_call_calc(self): """Nodes can only have a single incoming CALL_CALC link, independent of the source node.""" source_one = WorkflowNode() source_two = WorkflowNode() target = CalculationNode() target.add_incoming(source_one, LinkType.CALL_CALC, 'link_label') # Can only have a single incoming CALL_CALC link with self.assertRaises(ValueError): target.validate_incoming(source_one, LinkType.CALL_CALC, 'link_label') # Even when the source node is different with self.assertRaises(ValueError): target.validate_incoming(source_two, LinkType.CALL_CALC, 'link_label') # Or when the link label is different with self.assertRaises(ValueError): target.validate_incoming(source_one, LinkType.CALL_CALC, 'other_label')