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'}})
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'})
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"}})
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"})
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'}})
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'})