def test_stack_load_no_param_value_validation(self):
    'Test stack loading with disabled parameter value validation.'
    tmpl = template_format.parse('\n        heat_template_version: 2013-05-23\n        parameters:\n            flavor:\n                type: string\n                description: A flavor.\n                constraints:\n                    - custom_constraint: nova.flavor\n        resources:\n            a_resource:\n                type: GenericResourceType\n        ')
    fc = fakes.FakeClient()
    self.patchobject(nova.NovaClientPlugin, 'client', return_value=fc)
    fc.flavors = mock.Mock()
    flavor = collections.namedtuple('Flavor', ['id', 'name'])
    flavor.id = '1234'
    flavor.name = 'dummy'
    fc.flavors.get.return_value = flavor
    test_env = environment.Environment({'flavor': '1234'})
    self.stack = stack.Stack(self.ctx, 'stack_with_custom_constraint', template.Template(tmpl, env=test_env))
    self.stack.validate()
    self.stack.store()
    self.stack.create()
    stack_id = self.stack.id
    self.assertEqual((stack.Stack.CREATE, stack.Stack.COMPLETE), self.stack.state)
    loaded_stack = stack.Stack.load(self.ctx, stack_id=self.stack.id)
    self.assertEqual(stack_id, loaded_stack.parameters['OS::stack_id'])
    fc.flavors.get.assert_called_once_with('1234')
Test stack loading with disabled parameter value validation.
def test_stack_load_no_param_value_validation(self):
    
    tmpl = template_format.parse('\n        heat_template_version: 2013-05-23\n        parameters:\n            flavor:\n                type: string\n                description: A flavor.\n                constraints:\n                    - custom_constraint: nova.flavor\n        resources:\n            a_resource:\n                type: GenericResourceType\n        ')
    fc = fakes.FakeClient()
    self.patchobject(nova.NovaClientPlugin, 'client', return_value=fc)
    fc.flavors = mock.Mock()
    flavor = collections.namedtuple('Flavor', ['id', 'name'])
    flavor.id = '1234'
    flavor.name = 'dummy'
    fc.flavors.get.return_value = flavor
    test_env = environment.Environment({'flavor': '1234'})
    self.stack = stack.Stack(self.ctx, 'stack_with_custom_constraint', template.Template(tmpl, env=test_env))
    self.stack.validate()
    self.stack.store()
    self.stack.create()
    stack_id = self.stack.id
    self.assertEqual((stack.Stack.CREATE, stack.Stack.COMPLETE), self.stack.state)
    loaded_stack = stack.Stack.load(self.ctx, stack_id=self.stack.id)
    self.assertEqual(stack_id, loaded_stack.parameters['OS::stack_id'])
    fc.flavors.get.assert_called_once_with('1234')