Example #1
0
    def test_del_section_with_no_globals_section_in_template(self):
        template = {"a": "b"}

        expected = {"a": "b"}

        Globals.del_section(template)
        self.assertEquals(expected, template)
    def on_before_transform_template(self, template_dict):
        """
        Hook method that runs before a template gets transformed. In this method, we parse and process Globals section
        from the template (if present).

        :param dict template_dict: SAM template as a dictionary
        """

        try:
            global_section = Globals(template_dict)
        except InvalidGlobalsSectionException as ex:
            raise InvalidDocumentException([ex])

        # For each resource in template, try and merge with Globals if necessary
        template = SamTemplate(template_dict)
        for logicalId, resource in template.iterate():
            resource.properties = global_section.merge(resource.type,
                                                       resource.properties)
            template.set(logicalId, resource)

        # Remove the Globals section from template if necessary
        Globals.del_section(template_dict)

        # If there was a global openApiVersion flag, check and convert swagger
        # to the right version
        Globals.fix_openapi_definitions(template_dict)
    def test_del_section_with_no_globals_section_in_template(self):
        template = {
            "a": "b"
        }

        expected = {
            "a": "b"
        }

        Globals.del_section(template)
        self.assertEquals(expected, template)
    def on_before_transform_template(self, template_dict):
        """
        Hook method that runs before a template gets transformed. In this method, we parse and process Globals section
        from the template (if present).

        :param dict template_dict: SAM template as a dictionary
        """

        try:
            global_section = Globals(template_dict)
        except InvalidGlobalsSectionException as ex:
            raise InvalidDocumentException([ex])

        # For each resource in template, try and merge with Globals if necessary
        template = SamTemplate(template_dict)
        for logicalId, resource in template.iterate():
            resource.properties = global_section.merge(resource.type, resource.properties)
            template.set(logicalId, resource)

        # Remove the Globals section from template if necessary
        Globals.del_section(template_dict)
    def test_del_section_with_globals_section_in_template(self):
        template = self.template
        expected = {}

        Globals.del_section(template)
        self.assertEquals(expected, template)
Example #6
0
    def test_del_section_with_globals_section_in_template(self):
        template = self.template
        expected = {}

        Globals.del_section(template)
        self.assertEquals(expected, template)