diff options
author | Rabi Mishra <ramishra@redhat.com> | 2016-03-09 11:33:49 +0530 |
---|---|---|
committer | Kanagaraj Manickam <mkr1481@gmail.com> | 2016-03-10 19:17:17 +0530 |
commit | 0bf9463bfceb25d7b98a8fdd84b61521b8c013cb (patch) | |
tree | 0c921ae0ac0df058922bb2fec4f047f9005f8710 /heat/tests/test_translation_rule.py | |
parent | b86ef096f85427998fb82e830b469761258a1038 (diff) | |
download | heat-0bf9463bfceb25d7b98a8fdd84b61521b8c013cb.tar.gz |
Don't RESOLVE translate in resource init
We can completely remove 'RESOLVE' translations involving client
lookups in resource init. As we are doing translation before create
and update, it seems we can avoid it.
However, we would need other translations, like 'REPLACE' for property
vaidations(ex. required properties that would be replaced by deprecated
properties). This would be done only when strict_validate=True to avoid
this with template-validate.
Change-Id: Ie80bdd10726a8fc8a8787b78db93acffd333137f
Closes-Bug: #1554927
Partial-Bug: #1554380
Diffstat (limited to 'heat/tests/test_translation_rule.py')
-rw-r--r-- | heat/tests/test_translation_rule.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/heat/tests/test_translation_rule.py b/heat/tests/test_translation_rule.py index eaf87b12e..157975215 100644 --- a/heat/tests/test_translation_rule.py +++ b/heat/tests/test_translation_rule.py @@ -614,6 +614,35 @@ class TestTranslationRule(common.HeatTestCase): rule.execute_rule() self.assertEqual(data, props.data) + def test_resolve_rule_other_with_get_attr(self): + client_plugin, schema = self._test_resolve_rule() + + class DummyStack(dict): + pass + + class rsrc(object): + pass + + stack = DummyStack(another_res=rsrc()) + attr_func = cfn_funcs.GetAtt(stack, 'Fn::GetAtt', + ['another_res', 'name']) + data = {'far': attr_func} + props = properties.Properties(schema, data) + rule = translation.TranslationRule( + props, + translation.TranslationRule.RESOLVE, + ['far'], + client_plugin=client_plugin, + finder='find_name_id') + rule.execute_rule(client_resolve=False) + self.assertEqual(data, props.data) + + mock_getatt = self.patchobject(attr_func, 'result', + return_value='rose') + rule.execute_rule() + self.assertEqual('pink', props.get('far')) + self.assertEqual(1, mock_getatt.call_count) + def test_resolve_rule_other_with_entity(self): client_plugin, schema = self._test_resolve_rule() data = {'far': 'one'} |