def test_find_port_type(self): res = PortType(name="foo") obj = Definitions(port_types=[res]) self.assertEqual(res, obj.find_port_type("foo")) with self.assertRaises(DefinitionsValueError) as cm: obj.find_port_type("nope") self.assertEqual("Unknown PortType name: nope", str(cm.exception))
def map_port(cls, definitions: Definitions, port: ServicePort) -> Iterator[Class]: """Step 2: Match a ServicePort to a Binding and PortType object and delegate the process to the next entry point.""" binding = definitions.find_binding(text.suffix(port.binding)) port_type = definitions.find_port_type(text.suffix(binding.type)) elements = collections.concat(binding.extended_elements, port.extended_elements) config = cls.attributes(elements) yield from cls.map_binding(definitions, binding, port_type, config)