Merge "Assign parent_stack during validation"

This commit is contained in:
Jenkins 2016-03-02 17:27:53 +00:00 committed by Gerrit Code Review
commit edeae75de4
3 changed files with 21 additions and 0 deletions

View File

@ -227,6 +227,7 @@ class StackResource(resource.Resource):
stack_user_project_id=stack_user_project_id,
adopt_stack_data=adopt_data,
nested_depth=new_nested_depth)
nested.set_parent_stack(self.stack)
return nested
def _child_nested_depth(self):

View File

@ -257,6 +257,9 @@ class Stack(collections.Mapping):
return self._parent_stack[self.parent_resource_name]
def set_parent_stack(self, parent_stack):
self._parent_stack = parent_stack
def stored_context(self):
if self.user_creds_id:
creds_obj = ucreds_object.UserCreds.get_by_id(self.user_creds_id)

View File

@ -326,6 +326,23 @@ class StackResourceTest(StackResourceBaseTest):
self.assertRaises(exception.RequestLimitExceeded,
stk_resource.preview)
def test_parent_stack_existing_of_nested_stack(self):
parent_t = self.parent_stack.t
resource_defns = parent_t.resource_definitions(self.parent_stack)
stk_resource = MyImplementedStackResource(
'test',
resource_defns[self.ws_resname],
self.parent_stack)
stk_resource.child_params = mock.Mock(return_value={})
stk_resource.child_template = mock.Mock(
return_value=templatem.Template(self.simple_template,
stk_resource.child_params))
stk_resource._validate_nested_resources = mock.Mock()
nest_stack = stk_resource._parse_nested_stack(
"test_nest_stack", stk_resource.child_template(),
stk_resource.child_params())
self.assertEqual(nest_stack._parent_stack, self.parent_stack)
def test_preview_dict_validates_nested_resources(self):
parent_t = self.parent_stack.t
resource_defns = parent_t.resource_definitions(self.parent_stack)