Пример #1
0
    def test_return_value_if_cannot_handle(self, can_handle_mock):
        parameters = {"key": "value"}
        input = {"Fn::Sub": "${key}"}
        expected = {"Fn::Sub": "${key}"}

        sub = SubAction()
        can_handle_mock.return_value = False  # Simulate failure to handle the input. Result should be same as input
        self.assertEqual(expected,
                         sub.resolve_resource_id_refs(input, parameters))
Пример #2
0
    def test_sub_all_refs_with_dict_input(self):
        parameters = {"key1": "value1", "key2": "value2"}
        input = {"Fn::Sub": {"a": "key1", "b": "key2"}}
        expected = {"Fn::Sub": {"a": "key1", "b": "key2"}}

        sub = SubAction()
        result = sub.resolve_resource_id_refs(input, parameters)

        self.assertEqual(expected, result)
Пример #3
0
    def test_must_resolve_string_value(self):

        input = {"Fn::Sub": self.input_sub_value}
        expected = {"Fn::Sub": self.expected_output_sub_value}

        sub = SubAction()
        result = sub.resolve_resource_id_refs(input,
                                              self.supported_resource_id_refs)

        self.assertEqual(expected, result)
    def test_must_resolve_array_value(self):
        input = {
            "Fn::Sub": [self.input_sub_value, {"unknown":"a"}]
        }

        expected = {
            "Fn::Sub": [self.expected_output_sub_value, {"unknown": "a"}]
        }

        sub = SubAction()
        result = sub.resolve_resource_id_refs(input, self.supported_resource_id_refs)

        self.assertEqual(expected, result)
    def test_must_resolve_string_value(self):

        input = {
            "Fn::Sub": self.input_sub_value
        }
        expected = {
            "Fn::Sub": self.expected_output_sub_value
        }

        sub = SubAction()
        result = sub.resolve_resource_id_refs(input, self.supported_resource_id_refs)

        self.assertEqual(expected, result)
    def test_return_value_if_cannot_handle(self, can_handle_mock):
        parameters = {
            "key": "value"
        }
        input = {
            "Fn::Sub": "${key}"
        }
        expected = {
            "Fn::Sub": "${key}"
        }

        sub = SubAction()
        can_handle_mock.return_value = False # Simulate failure to handle the input. Result should be same as input
        self.assertEqual(expected, sub.resolve_resource_id_refs(input, parameters))
Пример #7
0
    def test_must_resolve_array_value(self):
        input = {"Fn::Sub": [self.input_sub_value, {"unknown": "a"}]}

        expected = {
            "Fn::Sub": [self.expected_output_sub_value, {
                "unknown": "a"
            }]
        }

        sub = SubAction()
        result = sub.resolve_resource_id_refs(input,
                                              self.supported_resource_id_refs)

        self.assertEqual(expected, result)
    def test_sub_all_refs_with_dict_input(self):
        parameters = {
            "key1": "value1",
            "key2": "value2"
        }
        input = {
            "Fn::Sub": {"a": "key1", "b": "key2"}
        }
        expected = {
            "Fn::Sub": {"a": "key1", "b": "key2"}
        }

        sub = SubAction()
        result = sub.resolve_resource_id_refs(input, parameters)

        self.assertEqual(expected, result)