def test_valid_type_reference(self, yaml_ast): service = ServiceTemplate.parse( yaml_ast(""" tosca_definitions_version: tosca_simple_yaml_1_3 node_types: my.Type: derived_from: tosca.nodes.Root """), None, None) ref = ReferenceWrapper("my.Type", None) ref.section_path = ("node_types", ) assert service.node_types["my.Type"] == ref.resolve_reference(service)
def test_invalid_reference(self, yaml_ast): service = ServiceTemplate.parse( yaml_ast(""" tosca_definitions_version: tosca_simple_yaml_1_3 node_types: my.Type: derived_from: tosca.nodes.Root """), None, None) ref = ReferenceWrapper("INVALID", None) ref.section_path = ("node_types", ) with pytest.raises(ParseError): ref.resolve_reference(service)
def test_valid_template_reference(self, yaml_ast): service = ServiceTemplate.parse( yaml_ast(""" tosca_definitions_version: tosca_simple_yaml_1_3 topology_template: node_templates: my_node: type: tosca.nodes.Root """), None, None) ref = ReferenceWrapper("my_node", None) ref.section_path = ("topology_template", "node_templates") target = service.topology_template.node_templates["my_node"] assert target == ref.resolve_reference(service)