コード例 #1
0
    def test_must_run_translator_plugins(self, resolve_params_mock,
                                         SamTranslatorWrapperMock):
        translator_instance = SamTranslatorWrapperMock.return_value = Mock()

        template = {"Key": "Value"}
        overrides = {'some': 'value'}

        SamBaseProvider.get_template(template, overrides)

        SamTranslatorWrapperMock.assert_called_once_with(template)
        translator_instance.run_plugins.assert_called_once()
        resolve_params_mock.assert_called_once()
コード例 #2
0
    def test_must_run_translator_plugins(self, resolve_template_mock,
                                         SamTranslatorWrapperMock,
                                         resource_metadata_normalizer_patch):
        resource_metadata_normalizer_patch.normalize.return_value = True
        resolve_template_mock.return_value = {}
        translator_instance = SamTranslatorWrapperMock.return_value = Mock()

        template = {"Key": "Value"}
        overrides = {"some": "value"}

        SamBaseProvider.get_template(template, overrides)

        SamTranslatorWrapperMock.assert_called_once_with(template)
        translator_instance.run_plugins.assert_called_once()
コード例 #3
0
    def __init__(self, template_dict, parameter_overrides=None, cwd=None):
        """
        Initialize the class with SAM template data. The template_dict (SAM Templated) is assumed
        to be valid, normalized and a dictionary. template_dict should be normalized by running any and all
        pre-processing before passing to this class.
        This class does not perform any syntactic validation of the template.

        After the class is initialized, changes to ``template_dict`` will not be reflected in here.
        You will need to explicitly update the class with new template, if necessary.

        Parameters
        ----------
        template_dict : dict
            SAM Template as a dictionary
        cwd : str
            Optional working directory with respect to which we will resolve relative path to Swagger file
        """

        self.template_dict = SamBaseProvider.get_template(
            template_dict, parameter_overrides)
        self.resources = self.template_dict.get("Resources", {})

        LOG.debug("%d resources found in the template", len(self.resources))

        # Store a set of apis
        self.cwd = cwd
        self.apis = self._extract_apis(self.resources)

        LOG.debug("%d APIs found in the template", len(self.apis))
コード例 #4
0
    def test_must_run_translator_plugins(self,
                                         resolve_params_mock,
                                         SamTranslatorWrapperMock,
                                         resource_metadata_normalizer_patch):
        translator_instance = SamTranslatorWrapperMock.return_value = Mock()

        parameter_resolved_template = {"Key": "Value", "Parameter": "Resolved"}
        resolve_params_mock.return_value = parameter_resolved_template

        template = {"Key": "Value"}
        overrides = {'some': 'value'}

        SamBaseProvider.get_template(template, overrides)

        SamTranslatorWrapperMock.assert_called_once_with(template)
        translator_instance.run_plugins.assert_called_once()
        resolve_params_mock.assert_called_once()
        resource_metadata_normalizer_patch.normalize.assert_called_once_with(parameter_resolved_template)