Exemplo n.º 1
0
    def test_transform_dict(self):
        input = {
            "a": {
                "baa": {
                    "key": "value"
                }
            },
            "b": [{
                "c": "d"
            }, "e", 2, [1, 2, {
                "Ref": "Foo"
            }]]
        }

        expected = [
            "a:", "  baa:", "    key: 'value'", "b:", "  - c: 'd'", "  - 'e'",
            "  - 2", "  -", "    - 1", "    - 2", {
                "Fn::Join": ["", ["    - ", {
                    "Ref": "Foo"
                }]]
            }
        ]

        result = CloudFormationTemplateTransformer._transform_dict(input)
        print(json.dumps(result, indent=4))
        self.assertEqual(expected, result)
Exemplo n.º 2
0
    def test_transform_dict_with_ref_in_nested_list(self):
        input = {
            "key": ["a", "b", ["a", {"Ref": "Foo"}]]
        }

        expected = [
            "key:",
            "  - 'a'",
            "  - 'b'",
            "  -",
            "    - 'a'",
            {
                "Fn::Join": [
                    "",
                    [
                        "    - ",
                        {
                            "Ref": "Foo"
                        }
                    ]
                ]
            }
        ]

        result = CloudFormationTemplateTransformer._transform_dict(input)
        self.assertEqual(expected, result)