Merge "map_replace allow noop colliding replacements"

This commit is contained in:
Jenkins 2016-12-23 14:08:27 +00:00 committed by Gerrit Code Review
commit 44dc6298f3
2 changed files with 10 additions and 1 deletions

View File

@ -767,7 +767,7 @@ class MapReplace(function.Function):
key = repl_keys.get(k)
if key is None:
key = k
elif key in in_map:
elif key in in_map and key != k:
# Keys collide
msg = _('key replacement %s collides with '
'a key in the input map')

View File

@ -1073,6 +1073,15 @@ class HOTemplateTest(common.HeatTestCase):
self.assertEqual({'f1': 'b1', 'F2': 'b2'},
resolved)
def test_map_replace_keys_collide_ok_equal(self):
# It's OK to replace a key with the same value
snippet = {'map_replace': [{'f1': 'b1', 'f2': 'b2'},
{'keys': {'f2': 'f2'}}]}
tmpl = template.Template(hot_newton_tpl_empty)
resolved = self.resolve(snippet, tmpl)
self.assertEqual({'f1': 'b1', 'f2': 'b2'},
resolved)
def test_map_replace_none_values(self):
snippet = {'map_replace': [{'f1': 'b1', 'f2': 'b2'},
{'values': None}]}