Make all assertEqual() calls conform to convention

It is a convention to have assertEqual() assertions invoked with
'expected value' before 'actual value', or else the debug output may
become very confusing.  This patch fixes about 100 violations in current
test cases where about 3580 assertEqual calls are made.

Closes-Bug: 1259292
Change-Id: I2e0474d9821716baf35a3bbb2952c63a84749dd3
This commit is contained in:
tengqm 2014-12-02 21:44:12 +08:00
parent 951841adbf
commit 3d2b7facda
18 changed files with 123 additions and 123 deletions

View File

@ -516,7 +516,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
stack_name = 'service_create_test_stack_exceeds_max' stack_name = 'service_create_test_stack_exceeds_max'
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self._test_stack_create, stack_name) self._test_stack_create, stack_name)
self.assertEqual(ex.exc_info[0], exception.RequestLimitExceeded) self.assertEqual(exception.RequestLimitExceeded, ex.exc_info[0])
self.assertIn("You have reached the maximum stacks per tenant", self.assertIn("You have reached the maximum stacks per tenant",
six.text_type(ex.exc_info[1])) six.text_type(ex.exc_info[1]))
@ -551,7 +551,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.create_stack, self.man.create_stack,
self.ctx, stack_name, self.ctx, stack_name,
template, params, None, {}) template, params, None, {})
self.assertEqual(ex.exc_info[0], exception.StackValidationFailed) self.assertEqual(exception.StackValidationFailed, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_adopt_with_params(self): def test_stack_adopt_with_params(self):
@ -642,7 +642,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.create_stack, self.man.create_stack,
ctx_no_pwd, stack_name, ctx_no_pwd, stack_name,
template, params, None, {}, None) template, params, None, {}, None)
self.assertEqual(ex.exc_info[0], exception.MissingCredentialError) self.assertEqual(exception.MissingCredentialError, ex.exc_info[0])
self.assertEqual( self.assertEqual(
'Missing required credential: X-Auth-Key', 'Missing required credential: X-Auth-Key',
six.text_type(ex.exc_info[1])) six.text_type(ex.exc_info[1]))
@ -651,7 +651,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.create_stack, self.man.create_stack,
ctx_no_user, stack_name, ctx_no_user, stack_name,
template, params, None, {}) template, params, None, {})
self.assertEqual(ex.exc_info[0], exception.MissingCredentialError) self.assertEqual(exception.MissingCredentialError, ex.exc_info[0])
self.assertEqual( self.assertEqual(
'Missing required credential: X-Auth-User', 'Missing required credential: X-Auth-User',
six.text_type(ex.exc_info[1])) six.text_type(ex.exc_info[1]))
@ -710,7 +710,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.man.create_stack, self.ctx, stack_name, self.man.create_stack, self.ctx, stack_name,
tpl, params, None, {}) tpl, params, None, {})
self.assertEqual(ex.exc_info[0], exception.RequestLimitExceeded) self.assertEqual(exception.RequestLimitExceeded, ex.exc_info[0])
self.assertIn(exception.StackResourceLimitExceeded.msg_fmt, self.assertIn(exception.StackResourceLimitExceeded.msg_fmt,
six.text_type(ex.exc_info[1])) six.text_type(ex.exc_info[1]))
@ -766,7 +766,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.man.delete_stack, self.man.delete_stack,
self.ctx, stack.identifier()) self.ctx, stack.identifier())
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_delete_acquired_lock(self): def test_stack_delete_acquired_lock(self):
@ -865,7 +865,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.man.delete_stack, self.man.delete_stack,
self.ctx, stack.identifier()) self.ctx, stack.identifier())
self.assertEqual(ex.exc_info[0], exception.StopActionFailed) self.assertEqual(exception.StopActionFailed, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_delete_other_engine_active_lock_succeeded(self): def test_stack_delete_other_engine_active_lock_succeeded(self):
@ -972,7 +972,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.assertEqual(old_stack.identifier(), result) self.assertEqual(old_stack.identifier(), result)
self.assertIsInstance(result, dict) self.assertIsInstance(result, dict)
self.assertTrue(result['stack_id']) self.assertTrue(result['stack_id'])
self.assertEqual(self.man.thread_group_mgr.events[sid], [evt_mock]) self.assertEqual([evt_mock], self.man.thread_group_mgr.events[sid])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_update_existing_parameters(self): def test_stack_update_existing_parameters(self):
@ -1022,7 +1022,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.assertEqual(old_stack.identifier(), result) self.assertEqual(old_stack.identifier(), result)
self.assertIsInstance(result, dict) self.assertIsInstance(result, dict)
self.assertTrue(result['stack_id']) self.assertTrue(result['stack_id'])
self.assertEqual(self.man.thread_group_mgr.events[sid], [evt_mock]) self.assertEqual([evt_mock], self.man.thread_group_mgr.events[sid])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_update_reuses_api_params(self): def test_stack_update_reuses_api_params(self):
@ -1091,7 +1091,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
dispatcher.ExpectedException, dispatcher.ExpectedException,
self.man.stack_cancel_update, self.ctx, old_stack.identifier()) self.man.stack_cancel_update, self.ctx, old_stack.identifier())
self.assertEqual(ex.exc_info[0], exception.NotSupported) self.assertEqual(exception.NotSupported, ex.exc_info[0])
self.assertIn("Cancelling update when stack is " self.assertIn("Cancelling update when stack is "
"('UPDATE', 'COMPLETE')", "('UPDATE', 'COMPLETE')",
six.text_type(ex.exc_info[1])) six.text_type(ex.exc_info[1]))
@ -1299,7 +1299,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.update_stack, self.ctx, self.man.update_stack, self.ctx,
old_stack.identifier(), tpl, params, old_stack.identifier(), tpl, params,
None, {}) None, {})
self.assertEqual(ex.exc_info[0], exception.RequestLimitExceeded) self.assertEqual(exception.RequestLimitExceeded, ex.exc_info[0])
self.assertIn(exception.StackResourceLimitExceeded.msg_fmt, self.assertIn(exception.StackResourceLimitExceeded.msg_fmt,
six.text_type(ex.exc_info[1])) six.text_type(ex.exc_info[1]))
@ -1335,7 +1335,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.update_stack, self.man.update_stack,
self.ctx, old_stack.identifier(), self.ctx, old_stack.identifier(),
template, params, None, api_args) template, params, None, api_args)
self.assertEqual(ex.exc_info[0], exception.StackValidationFailed) self.assertEqual(exception.StackValidationFailed, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_update_nonexist(self): def test_stack_update_nonexist(self):
@ -1350,7 +1350,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.update_stack, self.man.update_stack,
self.ctx, stack.identifier(), template, self.ctx, stack.identifier(), template,
params, None, {}) params, None, {})
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_update_no_credentials(self): def test_stack_update_no_credentials(self):
@ -1387,7 +1387,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.update_stack, self.ctx, self.man.update_stack, self.ctx,
old_stack.identifier(), old_stack.identifier(),
template, params, None, api_args) template, params, None, api_args)
self.assertEqual(ex.exc_info[0], exception.MissingCredentialError) self.assertEqual(exception.MissingCredentialError, ex.exc_info[0])
self.assertEqual( self.assertEqual(
'Missing required credential: X-Auth-Key', 'Missing required credential: X-Auth-Key',
six.text_type(ex.exc_info[1])) six.text_type(ex.exc_info[1]))
@ -1474,7 +1474,7 @@ class StackServiceUpdateActionsNotSupportedTest(common.HeatTestCase):
self.man.update_stack, self.man.update_stack,
self.ctx, old_stack.identifier(), template, self.ctx, old_stack.identifier(), template,
params, None, {}) params, None, {})
self.assertEqual(ex.exc_info[0], exception.NotSupported) self.assertEqual(exception.NotSupported, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
@ -1535,7 +1535,7 @@ class StackServiceActionsTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.man.stack_suspend, self.ctx, self.man.stack_suspend, self.ctx,
stack.identifier()) stack.identifier())
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_resume_nonexist(self): def test_stack_resume_nonexist(self):
@ -1547,7 +1547,7 @@ class StackServiceActionsTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.man.stack_resume, self.ctx, self.man.stack_resume, self.ctx,
stack.identifier()) stack.identifier())
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
def _mock_thread_start(self, stack_id, func, *args, **kwargs): def _mock_thread_start(self, stack_id, func, *args, **kwargs):
@ -1734,14 +1734,14 @@ class StackServiceTest(common.HeatTestCase):
def test_stack_identify_nonexist(self): def test_stack_identify_nonexist(self):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.identify_stack, self.ctx, 'wibble') self.eng.identify_stack, self.ctx, 'wibble')
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
@stack_context('service_create_existing_test_stack', False) @stack_context('service_create_existing_test_stack', False)
def test_stack_create_existing(self): def test_stack_create_existing(self):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.create_stack, self.ctx, self.eng.create_stack, self.ctx,
self.stack.name, self.stack.t.t, {}, None, {}) self.stack.name, self.stack.t.t, {}, None, {})
self.assertEqual(ex.exc_info[0], exception.StackExists) self.assertEqual(exception.StackExists, ex.exc_info[0])
@stack_context('service_name_tenants_test_stack', False) @stack_context('service_name_tenants_test_stack', False)
def test_stack_by_name_tenants(self): def test_stack_by_name_tenants(self):
@ -1833,7 +1833,7 @@ class StackServiceTest(common.HeatTestCase):
# pointing to an orphaned stack object. # pointing to an orphaned stack object.
self.stack = parser.Stack.load(self.ctx, stack_id=result['stack_id']) self.stack = parser.Stack.load(self.ctx, stack_id=result['stack_id'])
self.assertEqual(self.stack.identifier(), result) self.assertEqual(result, self.stack.identifier())
self.assertIsInstance(result, dict) self.assertIsInstance(result, dict)
self.assertTrue(result['stack_id']) self.assertTrue(result['stack_id'])
events = self.eng.list_events(self.ctx, self.stack.identifier()) events = self.eng.list_events(self.ctx, self.stack.identifier())
@ -2155,7 +2155,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.show_stack, self.eng.show_stack,
self.ctx, non_exist_identifier) self.ctx, non_exist_identifier)
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_describe_bad_tenant(self): def test_stack_describe_bad_tenant(self):
@ -2174,7 +2174,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.show_stack, self.eng.show_stack,
self.ctx, non_exist_identifier) self.ctx, non_exist_identifier)
self.assertEqual(ex.exc_info[0], exception.InvalidTenant) self.assertEqual(exception.InvalidTenant, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
@ -2337,7 +2337,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.describe_stack_resource, self.eng.describe_stack_resource,
self.ctx, non_exist_identifier, 'WebServer') self.ctx, non_exist_identifier, 'WebServer')
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
@ -2351,7 +2351,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.describe_stack_resource, self.eng.describe_stack_resource,
self.ctx, self.stack.identifier(), 'foo') self.ctx, self.stack.identifier(), 'foo')
self.assertEqual(ex.exc_info[0], exception.ResourceNotFound) self.assertEqual(exception.ResourceNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
@ -2366,7 +2366,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.describe_stack_resource, self.eng.describe_stack_resource,
self.ctx, self.stack.identifier(), 'foo') self.ctx, self.stack.identifier(), 'foo')
self.assertEqual(ex.exc_info[0], exception.Forbidden) self.assertEqual(exception.Forbidden, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
@ -2436,7 +2436,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.describe_stack_resources, self.eng.describe_stack_resources,
self.ctx, non_exist_identifier, 'WebServer') self.ctx, non_exist_identifier, 'WebServer')
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
@stack_context('find_phys_res_stack') @stack_context('find_phys_res_stack')
def test_find_physical_resource(self): def test_find_physical_resource(self):
@ -2455,7 +2455,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.find_physical_resource, self.eng.find_physical_resource,
self.ctx, 'foo') self.ctx, 'foo')
self.assertEqual(ex.exc_info[0], exception.PhysicalResourceNotFound) self.assertEqual(exception.PhysicalResourceNotFound, ex.exc_info[0])
@stack_context('service_resources_list_test_stack') @stack_context('service_resources_list_test_stack')
def test_stack_resources_list(self): def test_stack_resources_list(self):
@ -2531,7 +2531,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.list_stack_resources, self.eng.list_stack_resources,
self.ctx, non_exist_identifier) self.ctx, non_exist_identifier)
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
@ -2584,7 +2584,7 @@ class StackServiceTest(common.HeatTestCase):
dict(self.stack.identifier()), dict(self.stack.identifier()),
'resource_does_not_exist', 'resource_does_not_exist',
test_data) test_data)
self.assertEqual(ex.exc_info[0], exception.ResourceNotFound) self.assertEqual(exception.ResourceNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
self.stack.delete() self.stack.delete()
@ -2654,7 +2654,7 @@ class StackServiceTest(common.HeatTestCase):
self.eng.metadata_update, self.eng.metadata_update,
self.ctx, non_exist_identifier, self.ctx, non_exist_identifier,
'WebServer', test_metadata) 'WebServer', test_metadata)
self.assertEqual(ex.exc_info[0], exception.StackNotFound) self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
@stack_context('service_metadata_err_resource_test_stack', False) @stack_context('service_metadata_err_resource_test_stack', False)
@ -2669,7 +2669,7 @@ class StackServiceTest(common.HeatTestCase):
self.eng.metadata_update, self.eng.metadata_update,
self.ctx, dict(self.stack.identifier()), self.ctx, dict(self.stack.identifier()),
'NooServer', test_metadata) 'NooServer', test_metadata)
self.assertEqual(ex.exc_info[0], exception.ResourceNotFound) self.assertEqual(exception.ResourceNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
@ -2763,7 +2763,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.show_watch, self.eng.show_watch,
self.ctx, watch_name="nonexistent") self.ctx, watch_name="nonexistent")
self.assertEqual(ex.exc_info[0], exception.WatchRuleNotFound) self.assertEqual(exception.WatchRuleNotFound, ex.exc_info[0])
# Check the response has all keys defined in the engine API # Check the response has all keys defined in the engine API
for key in engine_api.WATCH_KEYS: for key in engine_api.WATCH_KEYS:
@ -2923,7 +2923,7 @@ class StackServiceTest(common.HeatTestCase):
self.eng.set_watch_state, self.eng.set_watch_state,
self.ctx, watch_name="nonexistent", self.ctx, watch_name="nonexistent",
state=state) state=state)
self.assertEqual(ex.exc_info[0], exception.WatchRuleNotFound) self.assertEqual(exception.WatchRuleNotFound, ex.exc_info[0])
self.m.VerifyAll() self.m.VerifyAll()
def test_stack_list_all_empty(self): def test_stack_list_all_empty(self):
@ -3017,7 +3017,7 @@ class StackServiceTest(common.HeatTestCase):
self.eng._validate_new_stack = mock.Mock(side_effect=exc) self.eng._validate_new_stack = mock.Mock(side_effect=exc)
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self._preview_stack) self._preview_stack)
self.assertEqual(ex.exc_info[0], exception.StackExists) self.assertEqual(exception.StackExists, ex.exc_info[0])
@mock.patch.object(service.api, 'format_stack_preview', new=mock.Mock()) @mock.patch.object(service.api, 'format_stack_preview', new=mock.Mock())
@mock.patch.object(service.parser, 'Stack') @mock.patch.object(service.parser, 'Stack')
@ -3028,7 +3028,7 @@ class StackServiceTest(common.HeatTestCase):
mock_parser.return_value = mock_parsed_stack mock_parser.return_value = mock_parsed_stack
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self._preview_stack) self._preview_stack)
self.assertEqual(ex.exc_info[0], exception.StackValidationFailed) self.assertEqual(exception.StackValidationFailed, ex.exc_info[0])
@mock.patch.object(service.db_api, 'stack_get_by_name') @mock.patch.object(service.db_api, 'stack_get_by_name')
def test_validate_new_stack_checks_existing_stack(self, mock_stack_get): def test_validate_new_stack_checks_existing_stack(self, mock_stack_get):
@ -3112,7 +3112,7 @@ class SoftwareConfigServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.show_software_config, self.engine.show_software_config,
self.ctx, config_id) self.ctx, config_id)
self.assertEqual(ex.exc_info[0], exception.NotFound) self.assertEqual(exception.NotFound, ex.exc_info[0])
config = self._create_software_config() config = self._create_software_config()
config_id = config['id'] config_id = config['id']
@ -3152,7 +3152,7 @@ class SoftwareConfigServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.show_software_config, self.engine.show_software_config,
self.ctx, config_id) self.ctx, config_id)
self.assertEqual(ex.exc_info[0], exception.NotFound) self.assertEqual(exception.NotFound, ex.exc_info[0])
def _create_software_deployment(self, config_id=None, input_values=None, def _create_software_deployment(self, config_id=None, input_values=None,
action='INIT', action='INIT',
@ -3273,7 +3273,7 @@ class SoftwareConfigServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.show_software_deployment, self.engine.show_software_deployment,
self.ctx, deployment_id) self.ctx, deployment_id)
self.assertEqual(ex.exc_info[0], exception.NotFound) self.assertEqual(exception.NotFound, ex.exc_info[0])
deployment = self._create_software_deployment() deployment = self._create_software_deployment()
self.assertIsNotNone(deployment) self.assertIsNotNone(deployment)
@ -3398,7 +3398,7 @@ class SoftwareConfigServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.delete_software_deployment, self.engine.delete_software_deployment,
self.ctx, deployment_id) self.ctx, deployment_id)
self.assertEqual(ex.exc_info[0], exception.NotFound) self.assertEqual(exception.NotFound, ex.exc_info[0])
deployment = self._create_software_deployment() deployment = self._create_software_deployment()
self.assertIsNotNone(deployment) self.assertIsNotNone(deployment)
@ -3508,7 +3508,7 @@ class ThreadGroupManagerTest(common.HeatTestCase):
self.tg_mock.add_thread.assert_called_with( self.tg_mock.add_thread.assert_called_with(
thm._start_with_trace, None, thm._start_with_trace, None,
self.f, *self.fargs, **self.fkwargs) self.f, *self.fargs, **self.fkwargs)
self.assertEqual(self.tg_mock.add_thread(), ret) self.assertEqual(ret, self.tg_mock.add_thread())
def test_tgm_add_timer(self): def test_tgm_add_timer(self):
stack_id = 'test' stack_id = 'test'
@ -3516,7 +3516,7 @@ class ThreadGroupManagerTest(common.HeatTestCase):
thm = service.ThreadGroupManager() thm = service.ThreadGroupManager()
thm.add_timer(stack_id, self.f, *self.fargs, **self.fkwargs) thm.add_timer(stack_id, self.f, *self.fargs, **self.fkwargs)
self.assertEqual(thm.groups[stack_id], self.tg_mock) self.assertEqual(self.tg_mock, thm.groups[stack_id])
self.tg_mock.add_timer.assert_called_with( self.tg_mock.add_timer.assert_called_with(
self.cfg_mock.CONF.periodic_interval, self.cfg_mock.CONF.periodic_interval,
self.f, *self.fargs, **self.fkwargs) self.f, *self.fargs, **self.fkwargs)
@ -3527,7 +3527,7 @@ class ThreadGroupManagerTest(common.HeatTestCase):
thm = service.ThreadGroupManager() thm = service.ThreadGroupManager()
thm.add_event(stack_id, e1) thm.add_event(stack_id, e1)
thm.add_event(stack_id, e2) thm.add_event(stack_id, e2)
self.assertEqual(thm.events[stack_id], [e1, e2]) self.assertEqual([e1, e2], thm.events[stack_id])
def test_tgm_remove_event(self): def test_tgm_remove_event(self):
stack_id = 'add_events_test' stack_id = 'add_events_test'
@ -3536,7 +3536,7 @@ class ThreadGroupManagerTest(common.HeatTestCase):
thm.add_event(stack_id, e1) thm.add_event(stack_id, e1)
thm.add_event(stack_id, e2) thm.add_event(stack_id, e2)
thm.remove_event(None, stack_id, e2) thm.remove_event(None, stack_id, e2)
self.assertEqual(thm.events[stack_id], [e1]) self.assertEqual([e1], thm.events[stack_id])
thm.remove_event(None, stack_id, e1) thm.remove_event(None, stack_id, e1)
self.assertNotIn(stack_id, thm.events) self.assertNotIn(stack_id, thm.events)
@ -3602,7 +3602,7 @@ class SnapshotServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.show_snapshot, self.engine.show_snapshot,
self.ctx, None, snapshot_id) self.ctx, None, snapshot_id)
self.assertEqual(ex.exc_info[0], exception.NotFound) self.assertEqual(exception.NotFound, ex.exc_info[0])
def test_create_snapshot(self): def test_create_snapshot(self):
stack = self._create_stack() stack = self._create_stack()
@ -3627,7 +3627,7 @@ class SnapshotServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.delete_snapshot, self.engine.delete_snapshot,
self.ctx, stack.identifier(), snapshot_id) self.ctx, stack.identifier(), snapshot_id)
self.assertEqual(ex.exc_info[0], exception.NotFound) self.assertEqual(exception.NotFound, ex.exc_info[0])
def test_delete_snapshot(self): def test_delete_snapshot(self):
stack = self._create_stack() stack = self._create_stack()
@ -3641,7 +3641,7 @@ class SnapshotServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException, ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.show_snapshot, self.ctx, self.engine.show_snapshot, self.ctx,
stack.identifier(), snapshot_id) stack.identifier(), snapshot_id)
self.assertEqual(ex.exc_info[0], exception.NotFound) self.assertEqual(exception.NotFound, ex.exc_info[0])
def test_list_snapshots(self): def test_list_snapshots(self):
stack = self._create_stack() stack = self._create_stack()

View File

@ -1426,7 +1426,7 @@ class KeystoneClientTest(common.HeatTestCase):
self.m.ReplayAll() self.m.ReplayAll()
ctx = utils.dummy_context() ctx = utils.dummy_context()
heat_ks_client = heat_keystoneclient.KeystoneClient(ctx) heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
self.assertEqual(heat_ks_client.url_for(**kwargs), service_url) self.assertEqual(service_url, heat_ks_client.url_for(**kwargs))
self.m.VerifyAll() self.m.VerifyAll()
def test_url_for(self): def test_url_for(self):

View File

@ -431,7 +431,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl = parser.Template(hot_tpl) tmpl = parser.Template(hot_tpl)
stack = parser.Stack(utils.dummy_context(), 'test_stack', tmpl) stack = parser.Stack(utils.dummy_context(), 'test_stack', tmpl)
snippet = {'list_join': ["\n", {'get_attr': ['rg', 'name']}]} snippet = {'list_join': ["\n", {'get_attr': ['rg', 'name']}]}
self.assertEqual(self.resolve(snippet, tmpl, stack), '') self.assertEqual('', self.resolve(snippet, tmpl, stack))
def test_str_replace(self): def test_str_replace(self):
"""Test str_replace function.""" """Test str_replace function."""
@ -827,12 +827,12 @@ class StackTest(test_parser.StackTest):
def test_set_param_id(self): def test_set_param_id(self):
tmpl = parser.Template(hot_tpl_empty) tmpl = parser.Template(hot_tpl_empty)
self.stack = parser.Stack(self.ctx, 'param_id_test', tmpl) self.stack = parser.Stack(self.ctx, 'param_id_test', tmpl)
self.assertEqual(self.stack.parameters['OS::stack_id'], 'None') self.assertEqual('None', self.stack.parameters['OS::stack_id'])
self.stack.store() self.stack.store()
stack_identifier = self.stack.identifier() stack_identifier = self.stack.identifier()
self.assertEqual(self.stack.parameters['OS::stack_id'], self.stack.id) self.assertEqual(self.stack.id, self.stack.parameters['OS::stack_id'])
self.assertEqual(self.stack.parameters['OS::stack_id'], self.assertEqual(stack_identifier.stack_id,
stack_identifier.stack_id) self.stack.parameters['OS::stack_id'])
self.m.VerifyAll() self.m.VerifyAll()
def test_set_wrong_param(self): def test_set_wrong_param(self):
@ -851,8 +851,8 @@ class StackTest(test_parser.StackTest):
self.stack = parser.Stack(self.ctx, 'update_stack_id_test', tmpl) self.stack = parser.Stack(self.ctx, 'update_stack_id_test', tmpl)
self.stack.store() self.stack.store()
self.stack.create() self.stack.create()
self.assertEqual(self.stack.state, self.assertEqual((parser.Stack.CREATE, parser.Stack.COMPLETE),
(parser.Stack.CREATE, parser.Stack.COMPLETE)) self.stack.state)
stack_id = self.stack.parameters['OS::stack_id'] stack_id = self.stack.parameters['OS::stack_id']
@ -864,24 +864,24 @@ class StackTest(test_parser.StackTest):
updated_stack = parser.Stack(self.ctx, 'updated_stack', tmpl2) updated_stack = parser.Stack(self.ctx, 'updated_stack', tmpl2)
self.stack.update(updated_stack) self.stack.update(updated_stack)
self.assertEqual(self.stack.state, self.assertEqual((parser.Stack.UPDATE, parser.Stack.COMPLETE),
(parser.Stack.UPDATE, parser.Stack.COMPLETE)) self.stack.state)
self.assertEqual(self.stack['AResource'].properties['Foo'], 'xyz') self.assertEqual('xyz', self.stack['AResource'].properties['Foo'])
self.assertEqual( self.assertEqual(stack_id,
self.stack['AResource'].metadata_get()['Bar'], stack_id) self.stack['AResource'].metadata_get()['Bar'])
def test_load_param_id(self): def test_load_param_id(self):
tmpl = parser.Template(hot_tpl_empty) tmpl = parser.Template(hot_tpl_empty)
self.stack = parser.Stack(self.ctx, 'param_load_id_test', tmpl) self.stack = parser.Stack(self.ctx, 'param_load_id_test', tmpl)
self.stack.store() self.stack.store()
stack_identifier = self.stack.identifier() stack_identifier = self.stack.identifier()
self.assertEqual(self.stack.parameters['OS::stack_id'], self.assertEqual(stack_identifier.stack_id,
stack_identifier.stack_id) self.stack.parameters['OS::stack_id'])
newstack = parser.Stack.load(self.ctx, stack_id=self.stack.id) newstack = parser.Stack.load(self.ctx, stack_id=self.stack.id)
self.assertEqual(newstack.parameters['OS::stack_id'], self.assertEqual(stack_identifier.stack_id,
stack_identifier.stack_id) newstack.parameters['OS::stack_id'])
def test_update_modify_param_ok_replace(self): def test_update_modify_param_ok_replace(self):
tmpl = { tmpl = {

View File

@ -123,7 +123,7 @@ class InstanceGroupTest(common.HeatTestCase):
instance_definition['Properties']) instance_definition['Properties'])
nested = rsrc.nested() nested = rsrc.nested()
self.assertEqual(nested.id, rsrc.resource_id) self.assertEqual(rsrc.resource_id, nested.id)
rsrc.delete() rsrc.delete()
self.m.VerifyAll() self.m.VerifyAll()

View File

@ -70,9 +70,9 @@ class LifecyclePluginUtilsTests(common.HeatTestCase):
ms = mock.Mock() ms = mock.Mock()
ms.__setattr__("action", 'A') ms.__setattr__("action", 'A')
lifecycle_plugin_utils.do_pre_ops(mc, ms, None, None) lifecycle_plugin_utils.do_pre_ops(mc, ms, None, None)
self.assertEqual(mc.pre_counter_for_unit_test, 1) self.assertEqual(1, mc.pre_counter_for_unit_test)
lifecycle_plugin_utils.do_post_ops(mc, ms, None, None) lifecycle_plugin_utils.do_post_ops(mc, ms, None, None)
self.assertEqual(mc.post_counter_for_unit_test, 1) self.assertEqual(1, mc.post_counter_for_unit_test)
return return
@ -80,16 +80,16 @@ class LifecyclePluginUtilsTests(common.HeatTestCase):
lcp_mappings = [] lcp_mappings = []
self.mock_lcp_class_map(lcp_mappings) self.mock_lcp_class_map(lcp_mappings)
pp_cis = lifecycle_plugin_utils.get_plug_point_class_instances() pp_cis = lifecycle_plugin_utils.get_plug_point_class_instances()
self.assertEqual(len(pp_cis), 0) self.assertEqual(0, len(pp_cis))
# order should change with sort # order should change with sort
lcp_mappings = [('A::B::C2', TestLifecycleCallout2), lcp_mappings = [('A::B::C2', TestLifecycleCallout2),
('A::B::C1', TestLifecycleCallout1)] ('A::B::C1', TestLifecycleCallout1)]
self.mock_lcp_class_map(lcp_mappings) self.mock_lcp_class_map(lcp_mappings)
pp_cis = lifecycle_plugin_utils.get_plug_point_class_instances() pp_cis = lifecycle_plugin_utils.get_plug_point_class_instances()
self.assertEqual(len(pp_cis), 2) self.assertEqual(2, len(pp_cis))
self.assertEqual(pp_cis[0].get_ordinal(), 100) self.assertEqual(100, pp_cis[0].get_ordinal())
self.assertEqual(pp_cis[1].get_ordinal(), 101) self.assertEqual(101, pp_cis[1].get_ordinal())
self.assertEqual(TestLifecycleCallout1, pp_cis[0].__class__) self.assertEqual(TestLifecycleCallout1, pp_cis[0].__class__)
self.assertEqual(TestLifecycleCallout2, pp_cis[1].__class__) self.assertEqual(TestLifecycleCallout2, pp_cis[1].__class__)
@ -98,9 +98,9 @@ class LifecyclePluginUtilsTests(common.HeatTestCase):
('A::B::C2', TestLifecycleCallout2)] ('A::B::C2', TestLifecycleCallout2)]
self.mock_lcp_class_map(lcp_mappings) self.mock_lcp_class_map(lcp_mappings)
pp_cis = lifecycle_plugin_utils.get_plug_point_class_instances() pp_cis = lifecycle_plugin_utils.get_plug_point_class_instances()
self.assertEqual(len(pp_cis), 2) self.assertEqual(2, len(pp_cis))
self.assertEqual(pp_cis[0].get_ordinal(), 100) self.assertEqual(100, pp_cis[0].get_ordinal())
self.assertEqual(pp_cis[1].get_ordinal(), 101) self.assertEqual(101, pp_cis[1].get_ordinal())
self.assertEqual(TestLifecycleCallout1, pp_cis[0].__class__) self.assertEqual(TestLifecycleCallout1, pp_cis[0].__class__)
self.assertEqual(TestLifecycleCallout2, pp_cis[1].__class__) self.assertEqual(TestLifecycleCallout2, pp_cis[1].__class__)
@ -110,9 +110,9 @@ class LifecyclePluginUtilsTests(common.HeatTestCase):
('A::B::C1', TestLifecycleCallout1)] ('A::B::C1', TestLifecycleCallout1)]
self.mock_lcp_class_map(lcp_mappings) self.mock_lcp_class_map(lcp_mappings)
pp_cis = lifecycle_plugin_utils.get_plug_point_class_instances() pp_cis = lifecycle_plugin_utils.get_plug_point_class_instances()
self.assertEqual(len(pp_cis), 3) self.assertEqual(3, len(pp_cis))
self.assertEqual(pp_cis[2].get_ordinal(), 100) self.assertEqual(100, pp_cis[2].get_ordinal())
self.assertEqual(pp_cis[0].get_ordinal(), 101) self.assertEqual(101, pp_cis[0].get_ordinal())
# (can sort fail partially? If so then this test may break) # (can sort fail partially? If so then this test may break)
self.assertEqual(TestLifecycleCallout2, pp_cis[0].__class__) self.assertEqual(TestLifecycleCallout2, pp_cis[0].__class__)
self.assertEqual(TestLifecycleCallout3, pp_cis[1].__class__) self.assertEqual(TestLifecycleCallout3, pp_cis[1].__class__)
@ -135,8 +135,8 @@ class LifecyclePluginUtilsTests(common.HeatTestCase):
except Exception: except Exception:
failed = True failed = True
self.assertTrue(failed) self.assertTrue(failed)
self.assertEqual(mc.pre_counter_for_unit_test, 1) self.assertEqual(1, mc.pre_counter_for_unit_test)
self.assertEqual(mc.post_counter_for_unit_test, 1) self.assertEqual(1, mc.post_counter_for_unit_test)
return return
@ -150,7 +150,7 @@ class LifecyclePluginUtilsTests(common.HeatTestCase):
ms = mock.Mock() ms = mock.Mock()
ms.__setattr__("action", 'A') ms.__setattr__("action", 'A')
lifecycle_plugin_utils.do_post_ops(mc, ms, None, None) lifecycle_plugin_utils.do_post_ops(mc, ms, None, None)
self.assertEqual(mc.post_counter_for_unit_test, 1) self.assertEqual(1, mc.post_counter_for_unit_test)
return return
@ -159,7 +159,7 @@ class LifecyclePluginUtilsTests(common.HeatTestCase):
ordinal = lcp.get_ordinal() ordinal = lcp.get_ordinal()
lcp.do_pre_op(None, None, None) lcp.do_pre_op(None, None, None)
lcp.do_post_op(None, None, None) lcp.do_post_op(None, None, None)
self.assertEqual(ordinal, 100) self.assertEqual(100, ordinal)
return return

View File

@ -101,7 +101,7 @@ Outputs:
stack = self.create_stack(self.test_template) stack = self.create_stack(self.test_template)
rsrc = stack['the_nested'] rsrc = stack['the_nested']
nested_name = utils.PhysName(stack.name, 'the_nested') nested_name = utils.PhysName(stack.name, 'the_nested')
self.assertEqual(rsrc.physical_resource_name(), nested_name) self.assertEqual(nested_name, rsrc.physical_resource_name())
arn_prefix = ('arn:openstack:heat::aaaa:stacks/%s/' % arn_prefix = ('arn:openstack:heat::aaaa:stacks/%s/' %
rsrc.physical_resource_name()) rsrc.physical_resource_name())
self.assertTrue(rsrc.FnGetRefId().startswith(arn_prefix)) self.assertTrue(rsrc.FnGetRefId().startswith(arn_prefix))

View File

@ -84,7 +84,7 @@ class NeutronClientPluginTests(NeutronClientPluginTestCase):
'9887157c-d092-40f5-b547-6361915fce7d'] '9887157c-d092-40f5-b547-6361915fce7d']
sgs_list = self.neutron_plugin.get_secgroup_uuids(sgs_uuid) sgs_list = self.neutron_plugin.get_secgroup_uuids(sgs_uuid)
self.assertEqual(sgs_list, sgs_uuid) self.assertEqual(sgs_uuid, sgs_list)
# test get from name, return only one # test get from name, return only one
sgs_non_uuid = ['security_group_1'] sgs_non_uuid = ['security_group_1']
expected_groups = ['0389f747-7785-4757-b7bb-2ab07e4b09c3'] expected_groups = ['0389f747-7785-4757-b7bb-2ab07e4b09c3']

View File

@ -58,7 +58,7 @@ class ParameterTest(testtools.TestCase):
p = self.new_parameter( p = self.new_parameter(
'p', {'Type': 'Json', 'NoEcho': 'true'}, {"a": 1}) 'p', {'Type': 'Json', 'NoEcho': 'true'}, {"a": 1})
self.assertTrue(p.hidden()) self.assertTrue(p.hidden())
self.assertEqual(str(p), '******') self.assertEqual('******', str(p))
def test_new_bad_type(self): def test_new_bad_type(self):
self.assertRaises(exception.InvalidSchemaError, self.new_parameter, self.assertRaises(exception.InvalidSchemaError, self.new_parameter,

View File

@ -1201,8 +1201,8 @@ class StackTest(common.HeatTestCase):
exp_prefix + 'None') exp_prefix + 'None')
self.stack.store() self.stack.store()
identifier = self.stack.identifier() identifier = self.stack.identifier()
self.assertEqual(self.stack.parameters['AWS::StackId'], self.assertEqual(exp_prefix + self.stack.id,
exp_prefix + self.stack.id) self.stack.parameters['AWS::StackId'])
self.assertEqual(self.stack.parameters['AWS::StackId'], self.assertEqual(self.stack.parameters['AWS::StackId'],
identifier.arn()) identifier.arn())
self.m.VerifyAll() self.m.VerifyAll()
@ -1564,8 +1564,8 @@ class StackTest(common.HeatTestCase):
self.assertIsNone(db_s) self.assertIsNone(db_s)
user_creds = db_api.user_creds_get(user_creds_id) user_creds = db_api.user_creds_get(user_creds_id)
self.assertIsNotNone(user_creds) self.assertIsNotNone(user_creds)
self.assertEqual(self.stack.state, self.assertEqual((parser.Stack.DELETE, parser.Stack.COMPLETE),
(parser.Stack.DELETE, parser.Stack.COMPLETE)) self.stack.state)
def test_delete_trust_fail(self): def test_delete_trust_fail(self):
cfg.CONF.set_override('deferred_auth_method', 'trusts') cfg.CONF.set_override('deferred_auth_method', 'trusts')

View File

@ -1681,12 +1681,12 @@ class PropertiesValidationTest(testtools.TestCase):
) )
} }
props = properties.Properties(schema, {}) props = properties.Properties(schema, {})
self.assertEqual(props.props['foo_sup'].support_status().status, self.assertEqual(support.SUPPORTED,
support.SUPPORTED) props.props['foo_sup'].support_status().status)
self.assertEqual(props.props['bar_dep'].support_status().status, self.assertEqual(support.DEPRECATED,
support.DEPRECATED) props.props['bar_dep'].support_status().status)
self.assertEqual(props.props['bar_dep'].support_status().message, self.assertEqual('Do not use this ever',
'Do not use this ever') props.props['bar_dep'].support_status().message)
def test_nested_properties_schema_invalid_property_in_list(self): def test_nested_properties_schema_invalid_property_in_list(self):
child_schema = {'Key': {'Type': 'String', child_schema = {'Key': {'Type': 'String',

View File

@ -111,44 +111,44 @@ Resources:
assert_min('[a-zA-Z0-9]', random_string, 32) assert_min('[a-zA-Z0-9]', random_string, 32)
self.assertRaises(exception.InvalidTemplateAttribute, self.assertRaises(exception.InvalidTemplateAttribute,
secret1.FnGetAtt, 'foo') secret1.FnGetAtt, 'foo')
self.assertEqual(random_string, secret1.FnGetRefId()) self.assertEqual(secret1.FnGetRefId(), random_string)
secret2 = stack['secret2'] secret2 = stack['secret2']
random_string = secret2.FnGetAtt('value') random_string = secret2.FnGetAtt('value')
assert_min('[a-zA-Z0-9]', random_string, 10) assert_min('[a-zA-Z0-9]', random_string, 10)
self.assertEqual(random_string, secret2.FnGetRefId()) self.assertEqual(secret2.FnGetRefId(), random_string)
secret3 = stack['secret3'] secret3 = stack['secret3']
random_string = secret3.FnGetAtt('value') random_string = secret3.FnGetAtt('value')
assert_min('[0-7]', random_string, 100) assert_min('[0-7]', random_string, 100)
self.assertEqual(random_string, secret3.FnGetRefId()) self.assertEqual(secret3.FnGetRefId(), random_string)
secret4 = stack['secret4'] secret4 = stack['secret4']
random_string = secret4.FnGetAtt('value') random_string = secret4.FnGetAtt('value')
self.assertEqual(len(random_string), 32) self.assertEqual(32, len(random_string))
assert_min('[0-9]', random_string, 1) assert_min('[0-9]', random_string, 1)
assert_min('[A-Z]', random_string, 1) assert_min('[A-Z]', random_string, 1)
assert_min('[a-z]', random_string, 20) assert_min('[a-z]', random_string, 20)
assert_min('[(),\[\]{}]', random_string, 1) assert_min('[(),\[\]{}]', random_string, 1)
assert_min('[$_]', random_string, 2) assert_min('[$_]', random_string, 2)
assert_min('@', random_string, 5) assert_min('@', random_string, 5)
self.assertEqual(random_string, secret4.FnGetRefId()) self.assertEqual(secret4.FnGetRefId(), random_string)
secret5 = stack['secret5'] secret5 = stack['secret5']
random_string = secret5.FnGetAtt('value') random_string = secret5.FnGetAtt('value')
self.assertEqual(len(random_string), 25) self.assertEqual(25, len(random_string))
assert_min('[0-9]', random_string, 1) assert_min('[0-9]', random_string, 1)
assert_min('[A-Z]', random_string, 1) assert_min('[A-Z]', random_string, 1)
assert_min('[a-z]', random_string, 20) assert_min('[a-z]', random_string, 20)
self.assertEqual(random_string, secret5.FnGetRefId()) self.assertEqual(secret5.FnGetRefId(), random_string)
secret6 = stack['secret6'] secret6 = stack['secret6']
random_string = secret6.FnGetAtt('value') random_string = secret6.FnGetAtt('value')
self.assertEqual(len(random_string), 10) self.assertEqual(10, len(random_string))
assert_min('[(),\[\]{}]', random_string, 1) assert_min('[(),\[\]{}]', random_string, 1)
assert_min('[$_]', random_string, 2) assert_min('[$_]', random_string, 2)
assert_min('@', random_string, 5) assert_min('@', random_string, 5)
self.assertEqual(random_string, secret6.FnGetRefId()) self.assertEqual(secret6.FnGetRefId(), random_string)
# Prove the name is returned before create sets the ID # Prove the name is returned before create sets the ID
secret6.resource_id = None secret6.resource_id = None
@ -210,7 +210,7 @@ Resources:
secret = stack['secret'] secret = stack['secret']
random_string = secret.FnGetAtt('value') random_string = secret.FnGetAtt('value')
self.assertEqual(512, len(random_string)) self.assertEqual(512, len(random_string))
self.assertEqual(random_string, secret.FnGetRefId()) self.assertEqual(secret.FnGetRefId(), random_string)
def test_exceeds_max_length(self): def test_exceeds_max_length(self):
template_random_string = ''' template_random_string = '''

View File

@ -388,18 +388,18 @@ class ServersTest(common.HeatTestCase):
server.FnGetAtt('addresses')['public'][0]['port']) server.FnGetAtt('addresses')['public'][0]['port'])
self.assertEqual('5678', self.assertEqual('5678',
server.FnGetAtt('addresses')['public'][1]['port']) server.FnGetAtt('addresses')['public'][1]['port'])
self.assertEqual( self.assertEqual(public_ip,
server.FnGetAtt('addresses')['public'][0]['addr'], public_ip) server.FnGetAtt('addresses')['public'][0]['addr'])
self.assertEqual( self.assertEqual(public_ip,
server.FnGetAtt('networks')['public'][0], public_ip) server.FnGetAtt('networks')['public'][0])
private_ip = return_server.networks['private'][0] private_ip = return_server.networks['private'][0]
self.assertEqual('1013', self.assertEqual('1013',
server.FnGetAtt('addresses')['private'][0]['port']) server.FnGetAtt('addresses')['private'][0]['port'])
self.assertEqual( self.assertEqual(private_ip,
server.FnGetAtt('addresses')['private'][0]['addr'], private_ip) server.FnGetAtt('addresses')['private'][0]['addr'])
self.assertEqual( self.assertEqual(private_ip,
server.FnGetAtt('networks')['private'][0], private_ip) server.FnGetAtt('networks')['private'][0])
self.assertIn( self.assertIn(
server.FnGetAtt('first_address'), (private_ip, public_ip)) server.FnGetAtt('first_address'), (private_ip, public_ip))
@ -2149,7 +2149,7 @@ class ServersTest(common.HeatTestCase):
mox.Replay(get) mox.Replay(get)
self.m.ReplayAll() self.m.ReplayAll()
self.assertEqual(server._resolve_attribute("accessIPv4"), '') self.assertEqual('', server._resolve_attribute("accessIPv4"))
self.m.VerifyAll() self.m.VerifyAll()
def test_default_instance_user(self): def test_default_instance_user(self):

View File

@ -1228,9 +1228,9 @@ class DBAPIRawTemplateTest(common.HeatTestCase):
updated_tp = db_api.raw_template_update(self.ctx, updated_tp = db_api.raw_template_update(self.ctx,
orig_tp.id, new_values) orig_tp.id, new_values)
self.assertEqual(updated_tp.id, orig_tp.id) self.assertEqual(orig_tp.id, updated_tp.id)
self.assertEqual(updated_tp.template, new_t) self.assertEqual(new_t, updated_tp.template)
self.assertEqual(updated_tp.files, new_files) self.assertEqual(new_files, updated_tp.files)
class DBAPIUserCredsTest(common.HeatTestCase): class DBAPIUserCredsTest(common.HeatTestCase):

View File

@ -235,7 +235,7 @@ class StructuredDeploymentWithStrictInputTest(common.HeatTestCase):
expected = {'foo': ['baz', 'baz2']} expected = {'foo': ['baz', 'baz2']}
result = self.deployment._build_derived_config( result = self.deployment._build_derived_config(
'CREATE', self.source, self.inputs, {}) 'CREATE', self.source, self.inputs, {})
self.assertEqual(result, expected) self.assertEqual(expected, result)
class StructuredDeploymentParseTest(common.HeatTestCase): class StructuredDeploymentParseTest(common.HeatTestCase):
@ -375,7 +375,7 @@ class StructuredDeploymentParseMethodsTest(common.HeatTestCase):
input_key = 'get_input' input_key = 'get_input'
expected = 'bar' expected = 'bar'
result = sc.StructuredDeployment.get_input_key_arg(snippet, input_key) result = sc.StructuredDeployment.get_input_key_arg(snippet, input_key)
self.assertEqual(result, expected) self.assertEqual(expected, result)
def test_get_key_args_long_snippet(self): def test_get_key_args_long_snippet(self):
snippet = {'get_input': 'bar', 'second': 'foo'} snippet = {'get_input': 'bar', 'second': 'foo'}
@ -399,7 +399,7 @@ class StructuredDeploymentParseMethodsTest(common.HeatTestCase):
inputs = {'bar': 'baz', 'foo': 'foo2'} inputs = {'bar': 'baz', 'foo': 'foo2'}
res = sc.StructuredDeployment.get_input_key_value('bar', inputs, False) res = sc.StructuredDeployment.get_input_key_value('bar', inputs, False)
expected = 'baz' expected = 'baz'
self.assertEqual(res, expected) self.assertEqual(expected, res)
def test_get_input_key_value_raise_exception(self): def test_get_input_key_value_raise_exception(self):
inputs = {'bar': 'baz', 'foo': 'foo2'} inputs = {'bar': 'baz', 'foo': 'foo2'}

View File

@ -677,7 +677,7 @@ class SwiftSignalTest(common.HeatTestCase):
st.create() st.create()
self.assertEqual(('CREATE', 'COMPLETE'), st.state) self.assertEqual(('CREATE', 'COMPLETE'), st.state)
self.assertEqual(handle.FnGetAtt('token'), '') self.assertEqual('', handle.FnGetAtt('token'))
@mock.patch.object(swift.SwiftClientPlugin, '_create') @mock.patch.object(swift.SwiftClientPlugin, '_create')
@mock.patch.object(resource.Resource, 'physical_resource_name') @mock.patch.object(resource.Resource, 'physical_resource_name')

View File

@ -102,7 +102,7 @@ class RetryBackoffExponentialTest(common.HeatTestCase):
def test_backoff_delay(self): def test_backoff_delay(self):
delay = util.retry_backoff_delay( delay = util.retry_backoff_delay(
self.attempt, self.scale_factor) self.attempt, self.scale_factor)
self.assertEqual(delay, self.delay) self.assertEqual(self.delay, delay)
class RetryBackoffJitterTest(common.HeatTestCase): class RetryBackoffJitterTest(common.HeatTestCase):

View File

@ -375,7 +375,7 @@ Resources:
t = template_format.parse(self.test_template) t = template_format.parse(self.test_template)
stack = self.parse_stack(t) stack = self.parse_stack(t)
scheduler.TaskRunner(stack.create)() scheduler.TaskRunner(stack.create)()
self.assertEqual(stack.state, (stack.CREATE, stack.FAILED)) self.assertEqual((stack.CREATE, stack.FAILED), stack.state)
scheduler.TaskRunner(stack.delete)() scheduler.TaskRunner(stack.delete)()
self.m.VerifyAll() self.m.VerifyAll()
@ -789,7 +789,7 @@ Resources:
self.assertResourceState(attachment, 'the_attachment') self.assertResourceState(attachment, 'the_attachment')
route_table = stack['the_route_table'] route_table = stack['the_route_table']
self.assertEqual(list(attachment._vpc_route_tables()), [route_table]) self.assertEqual([route_table], list(attachment._vpc_route_tables()))
stack.delete() stack.delete()
self.m.VerifyAll() self.m.VerifyAll()

View File

@ -757,7 +757,7 @@ class WaitConditionUpdateTest(common.HeatTestCase):
self.stack.create() self.stack.create()
rsrc = self.stack['WaitForTheHandle'] rsrc = self.stack['WaitForTheHandle']
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE)) self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll() self.m.VerifyAll()
self.m.UnsetStubs() self.m.UnsetStubs()