예제 #1
0
 def test_to_json(self):
     """Verify to_json method operation."""
     expected_json = json.dumps(
         {
             "AWSTemplateFormatVersion": "2010-09-09",
             "Description": "TestTemplate",
             "Parameters": {
                 "Param1": {
                     "Type": "String"
                 },
                 "Param2": {
                     "Default": "default",
                     "Type": "CommaDelimitedList"
                 }
             },
             "Resources": {
                 "Dummy": {
                     "Type": "AWS::CloudFormation::WaitConditionHandle"
                 }
             },
             "Outputs": {
                 "DummyId": {
                     "Value": "dummy-1234"
                 }
             }
         },
         sort_keys=True,
         indent=4)
     self.assertEqual(
         RawTemplateBlueprint(
             name="test",
             context=mock_context(),
             raw_template_path=RAW_JSON_TEMPLATE_PATH).to_json(),
         expected_json)
예제 #2
0
 def test_get_required_parameter_definitions_yaml(self):  # noqa pylint: disable=invalid-name
     """Verify get_required_param... method with yaml raw template."""
     blueprint = RawTemplateBlueprint(
         name="test",
         context=MagicMock(),
         raw_template_path=RAW_YAML_TEMPLATE_PATH)
     self.assertEqual(blueprint.get_required_parameter_definitions(),
                      {"Param1": {
                          "Type": "String"
                      }})
예제 #3
0
 def test_get_parameter_definitions_json(self):  # noqa pylint: disable=invalid-name
     """Verify get_parameter_definitions method with json raw template."""
     blueprint = RawTemplateBlueprint(
         name="test",
         context=MagicMock(),
         raw_template_path=RAW_JSON_TEMPLATE_PATH)
     parameters = blueprint.get_parameter_definitions()
     self.assertEqual(
         parameters,
         {"Param1": {"Type": "String"},
          "Param2": {"Default": "default",
                     "Type": "CommaDelimitedList"}})
예제 #4
0
 def test_j2_to_json(self):
     """Verify jinja2 template parsing."""
     expected_json = json.dumps(
         {
             "AWSTemplateFormatVersion": "2010-09-09",
             "Description": "TestTemplate",
             "Parameters": {
                 "Param1": {
                     "Type": "String"
                 },
                 "Param2": {
                     "Default": "default",
                     "Type": "CommaDelimitedList"
                 }
             },
             "Resources": {
                 "Dummy": {
                     "Type": "AWS::CloudFormation::WaitConditionHandle"
                 }
             },
             "Outputs": {
                 "DummyId": {
                     "Value": "dummy-bar-param1val-foo-1234"
                 }
             }
         },
         sort_keys=True,
         indent=4)
     blueprint = RawTemplateBlueprint(
         name="stack1",
         context=mock_context(extra_config_args={
             'stacks': [{
                 'name': 'stack1',
                 'template_path': 'unused',
                 'variables': {
                     'Param1': 'param1val',
                     'bar': 'foo'
                 }
             }]
         },
                              environment={'foo': 'bar'}),
         raw_template_path=RAW_J2_TEMPLATE_PATH)
     blueprint.resolve_variables(
         [Variable("Param1", "param1val"),
          Variable("bar", "foo")])
     self.assertEqual(expected_json, blueprint.to_json())