Use region from config in functional tests

We seem to be using hardcoded region in some inline
templates of fucntional tests. They would fail if
the region name is different. This changes to use
it from the config.

Change-Id: Iafd1251545e00c6cba292b042352b1ef34da81e0
Closes-Bug: #1560585
This commit is contained in:
Rabi Mishra 2016-03-23 10:20:21 +05:30
parent 8b02644d63
commit cbed62355c

View File

@ -45,6 +45,9 @@ outputs:
def setUp(self): def setUp(self):
super(RemoteStackTest, self).setUp() super(RemoteStackTest, self).setUp()
# replacing the template region with the one from the config
self.template = self.template.replace('RegionOne',
self.conf.region)
def test_remote_stack_alone(self): def test_remote_stack_alone(self):
stack_id = self.stack_create(template=self.remote_template) stack_id = self.stack_create(template=self.remote_template)
@ -78,7 +81,7 @@ outputs:
self.assertEqual(remote_resources, self.list_resources(remote_id)) self.assertEqual(remote_resources, self.list_resources(remote_id))
def test_stack_create_bad_region(self): def test_stack_create_bad_region(self):
tmpl_bad_region = self.template.replace('RegionOne', 'DARKHOLE') tmpl_bad_region = self.template.replace(self.conf.region, 'DARKHOLE')
files = {'remote_stack.yaml': self.remote_template} files = {'remote_stack.yaml': self.remote_template}
kwargs = { kwargs = {
'template': tmpl_bad_region, 'template': tmpl_bad_region,
@ -98,8 +101,9 @@ outputs:
ex = self.assertRaises(exc.HTTPBadRequest, self.stack_create, **kwargs) ex = self.assertRaises(exc.HTTPBadRequest, self.stack_create, **kwargs)
error_msg = ('ERROR: Failed validating stack template using Heat ' error_msg = ('ERROR: Failed validating stack template using Heat '
'endpoint at region "RegionOne" due to ' 'endpoint at region "%s" due to '
'"ERROR: The template section is invalid: resource"') '"ERROR: The template section is '
'invalid: resource"') % self.conf.region
self.assertEqual(error_msg, six.text_type(ex)) self.assertEqual(error_msg, six.text_type(ex))
def test_stack_update(self): def test_stack_update(self):