Merge "Correct behaviour of update_replace property in test resource"

This commit is contained in:
Zuul 2018-04-20 20:13:55 +00:00 committed by Gerrit Code Review
commit b2b3aaa5ba
3 changed files with 8 additions and 5 deletions

View File

@ -178,8 +178,8 @@ class TestResource(resource.Resource):
def needs_replace_with_prop_diff(self, changed_properties_set, def needs_replace_with_prop_diff(self, changed_properties_set,
after_props, before_props): after_props, before_props):
if self.UPDATE_REPLACE in changed_properties_set: if self.VALUE in changed_properties_set:
return bool(after_props.get(self.UPDATE_REPLACE)) return after_props[self.UPDATE_REPLACE]
def handle_update(self, json_snippet, tmpl_diff, prop_diff): def handle_update(self, json_snippet, tmpl_diff, prop_diff):
self.properties = json_snippet.properties(self.properties_schema, self.properties = json_snippet.properties(self.properties_schema,

View File

@ -4366,7 +4366,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
ev.assert_called_with(res.UPDATE, res.FAILED, ev.assert_called_with(res.UPDATE, res.FAILED,
'update is restricted for resource.') 'update is restricted for resource.')
def test_replace_rstricted(self): def test_replace_restricted(self):
self.env_snippet = {u'resource_registry': { self.env_snippet = {u'resource_registry': {
u'resources': { u'resources': {
'bar': {'restricted_actions': 'replace'} 'bar': {'restricted_actions': 'replace'}
@ -4378,6 +4378,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
res = self.create_resource() res = self.create_resource()
ev = self.patchobject(res, '_add_event') ev = self.patchobject(res, '_add_event')
props = self.tmpl['resources']['bar']['properties'] props = self.tmpl['resources']['bar']['properties']
props['value'] = '4567'
props['update_replace'] = True props['update_replace'] = True
snippet = rsrc_defn.ResourceDefinition('bar', snippet = rsrc_defn.ResourceDefinition('bar',
'TestResourceType', 'TestResourceType',
@ -4392,7 +4393,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
ev.assert_called_with(res.UPDATE, res.FAILED, ev.assert_called_with(res.UPDATE, res.FAILED,
'replace is restricted for resource.') 'replace is restricted for resource.')
def test_update_with_replace_rstricted(self): def test_update_with_replace_restricted(self):
self.env_snippet = {u'resource_registry': { self.env_snippet = {u'resource_registry': {
u'resources': { u'resources': {
'bar': {'restricted_actions': 'replace'} 'bar': {'restricted_actions': 'replace'}
@ -4413,7 +4414,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
ev.assert_called_with(res.UPDATE, res.COMPLETE, ev.assert_called_with(res.UPDATE, res.COMPLETE,
'state changed') 'state changed')
def test_replace_with_update_rstricted(self): def test_replace_with_update_restricted(self):
self.env_snippet = {u'resource_registry': { self.env_snippet = {u'resource_registry': {
u'resources': { u'resources': {
'bar': {'restricted_actions': 'update'} 'bar': {'restricted_actions': 'update'}
@ -4426,6 +4427,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
ev = self.patchobject(res, '_add_event') ev = self.patchobject(res, '_add_event')
prep_replace = self.patchobject(res, 'prepare_for_replace') prep_replace = self.patchobject(res, 'prepare_for_replace')
props = self.tmpl['resources']['bar']['properties'] props = self.tmpl['resources']['bar']['properties']
props['value'] = '4567'
props['update_replace'] = True props['update_replace'] = True
snippet = rsrc_defn.ResourceDefinition('bar', snippet = rsrc_defn.ResourceDefinition('bar',
'TestResourceType', 'TestResourceType',

View File

@ -96,6 +96,7 @@ class UpdateRestrictedStackTest(functional_base.FunctionalTestsBase):
update_template = test_template.copy() update_template = test_template.copy()
props = update_template['resources']['bar']['properties'] props = update_template['resources']['bar']['properties']
props['value'] = '4567'
props['update_replace'] = True props['update_replace'] = True
# check replace fails - with 'both' restricted # check replace fails - with 'both' restricted