Exemplo n.º 1
0
    def test_scan_executes_value_handler_for_all_matching_prefixes(self):
        dictionary = {'a': 'foo123', 'b': {'c': 'foo234'}}
        handler = Mock()
        handler.return_value = "foo"

        result = CloudFormationTemplateTransformer.scan(dictionary, [], [handler])
        expected_calls = [mock.call('foo123'), mock.call('foo234')]

        self.assertEqual(sorted(expected_calls), sorted(handler.mock_calls))
        self.assertEqual(result, {'a': 'foo', 'b': {'c': 'foo'}})
Exemplo n.º 2
0
    def test_scan_executes_key_handler_for_all_matching_keys(self):
        dictionary = {'|key|': 'value'}
        handler = Mock()
        handler.return_value = 'new-key', 'new-value'

        result = CloudFormationTemplateTransformer.scan(dictionary, [handler], [])
        expected_calls = [mock.call('|key|', 'value')]

        self.assertEqual(expected_calls, handler.mock_calls)
        self.assertEqual(result, {'new-key': 'new-value'})
Exemplo n.º 3
0
    def test_scan_executes_value_handler_for_all_matching_prefixes(self):
        dictionary = {"a": "foo123", "b": {"c": "foo234"}}
        handler = Mock()
        handler.return_value = "foo"

        result = CloudFormationTemplateTransformer.scan(dictionary, [], [handler])
        expected_calls = [mock.call("foo123"), mock.call("foo234")]

        self.assertEqual(sorted(expected_calls), sorted(handler.mock_calls))
        self.assertEqual(result, {"a": "foo", "b": {"c": "foo"}})
Exemplo n.º 4
0
    def test_scan_executes_key_handler_for_all_matching_keys(self):
        dictionary = {"|key|": "value"}
        handler = Mock()
        handler.return_value = "new-key", "new-value"

        result = CloudFormationTemplateTransformer.scan(dictionary, [handler], [])
        expected_calls = [mock.call("|key|", "value")]

        self.assertEqual(expected_calls, handler.mock_calls)
        self.assertEqual(result, {"new-key": "new-value"})
Exemplo n.º 5
0
    def test_scan_executes_value_handler_for_all_matching_prefixes(self):
        dictionary = {'a': 'foo123', 'b': {'c': 'foo234'}}
        handler = Mock()
        handler.return_value = "foo"

        result = CloudFormationTemplateTransformer.scan(
            dictionary, [], [handler])
        expected_calls = [mock.call('foo123'), mock.call('foo234')]

        self.assertEqual(sorted(expected_calls), sorted(handler.mock_calls))
        self.assertEqual(result, {'a': 'foo', 'b': {'c': 'foo'}})
Exemplo n.º 6
0
    def test_scan_executes_key_handler_for_all_matching_keys(self):
        dictionary = {'|key|': 'value'}
        handler = Mock()
        handler.return_value = 'new-key', 'new-value'

        result = CloudFormationTemplateTransformer.scan(
            dictionary, [handler], [])
        expected_calls = [mock.call('|key|', 'value')]

        self.assertEqual(expected_calls, handler.mock_calls)
        self.assertEqual(result, {'new-key': 'new-value'})