Exemplo n.º 1
0
def parse_template(template):
    """ parse instantiates a Template object with the provided string contents
    of the template and returns a dict of all the resources defined within it.
    """
    temp = Template(template)
    temp.reduce_functions()
    return temp.parse_resources()
Exemplo n.º 2
0
def parse_template(template):
    """ parse instantiates a Template object with the provided string contents
    of the template and returns a dict of all the resources defined within it.
    """
    temp = Template(template)
    temp.reduce_functions()
    return temp.parse_resources()
Exemplo n.º 3
0
    def test_parse_resources(self):
        """ test_parse_resources tests that running the resource extraction
        procedure will yield the appropriate set of resources:
        """
        LOG.debug("testing resource parsing on '%s'", self._resource_parsing_test_data)

        temp = Template(self._resource_parsing_test_data)
        parsed_resources = temp.parse_resources()

        input_resources = yaml.load(self._resource_parsing_test_data)[self._field_names["resources"]]

        # ensure all the resources defined in the input template have a
        # corresponding Resource instance created for them:
        for res_name, res_data in input_resources.items():
            self.assertTrue(res_name in parsed_resources)
            self.assertDictEqual(
                parsed_resources[res_name].properties, res_data.get(self._field_names["properties"], {})
            )
Exemplo n.º 4
0
    def test_parse_resources(self):
        """ test_parse_resources tests that running the resource extraction
        procedure will yield the appropriate set of resources:
        """
        LOG.debug("testing resource parsing on '%s'",
                  self._resource_parsing_test_data)

        temp = Template(self._resource_parsing_test_data)
        parsed_resources = temp.parse_resources()

        input_resources = yaml.load(
            self._resource_parsing_test_data)[self._field_names["resources"]]

        # ensure all the resources defined in the input template have a
        # corresponding Resource instance created for them:
        for res_name, res_data in input_resources.items():
            self.assertTrue(res_name in parsed_resources)
            self.assertDictEqual(
                parsed_resources[res_name].properties,
                res_data.get(self._field_names["properties"], {}))