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'
ex = self.assertRaises(dispatcher.ExpectedException,
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",
six.text_type(ex.exc_info[1]))
@ -551,7 +551,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.create_stack,
self.ctx, stack_name,
template, params, None, {})
self.assertEqual(ex.exc_info[0], exception.StackValidationFailed)
self.assertEqual(exception.StackValidationFailed, ex.exc_info[0])
self.m.VerifyAll()
def test_stack_adopt_with_params(self):
@ -642,7 +642,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.create_stack,
ctx_no_pwd, stack_name,
template, params, None, {}, None)
self.assertEqual(ex.exc_info[0], exception.MissingCredentialError)
self.assertEqual(exception.MissingCredentialError, ex.exc_info[0])
self.assertEqual(
'Missing required credential: X-Auth-Key',
six.text_type(ex.exc_info[1]))
@ -651,7 +651,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.create_stack,
ctx_no_user, stack_name,
template, params, None, {})
self.assertEqual(ex.exc_info[0], exception.MissingCredentialError)
self.assertEqual(exception.MissingCredentialError, ex.exc_info[0])
self.assertEqual(
'Missing required credential: X-Auth-User',
six.text_type(ex.exc_info[1]))
@ -710,7 +710,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.man.create_stack, self.ctx, stack_name,
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,
six.text_type(ex.exc_info[1]))
@ -766,7 +766,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.man.delete_stack,
self.ctx, stack.identifier())
self.assertEqual(ex.exc_info[0], exception.StackNotFound)
self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll()
def test_stack_delete_acquired_lock(self):
@ -865,7 +865,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.man.delete_stack,
self.ctx, stack.identifier())
self.assertEqual(ex.exc_info[0], exception.StopActionFailed)
self.assertEqual(exception.StopActionFailed, ex.exc_info[0])
self.m.VerifyAll()
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.assertIsInstance(result, dict)
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()
def test_stack_update_existing_parameters(self):
@ -1022,7 +1022,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.assertEqual(old_stack.identifier(), result)
self.assertIsInstance(result, dict)
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()
def test_stack_update_reuses_api_params(self):
@ -1091,7 +1091,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
dispatcher.ExpectedException,
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 "
"('UPDATE', 'COMPLETE')",
six.text_type(ex.exc_info[1]))
@ -1299,7 +1299,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.update_stack, self.ctx,
old_stack.identifier(), 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,
six.text_type(ex.exc_info[1]))
@ -1335,7 +1335,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.update_stack,
self.ctx, old_stack.identifier(),
template, params, None, api_args)
self.assertEqual(ex.exc_info[0], exception.StackValidationFailed)
self.assertEqual(exception.StackValidationFailed, ex.exc_info[0])
self.m.VerifyAll()
def test_stack_update_nonexist(self):
@ -1350,7 +1350,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.update_stack,
self.ctx, stack.identifier(), template,
params, None, {})
self.assertEqual(ex.exc_info[0], exception.StackNotFound)
self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll()
def test_stack_update_no_credentials(self):
@ -1387,7 +1387,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.update_stack, self.ctx,
old_stack.identifier(),
template, params, None, api_args)
self.assertEqual(ex.exc_info[0], exception.MissingCredentialError)
self.assertEqual(exception.MissingCredentialError, ex.exc_info[0])
self.assertEqual(
'Missing required credential: X-Auth-Key',
six.text_type(ex.exc_info[1]))
@ -1474,7 +1474,7 @@ class StackServiceUpdateActionsNotSupportedTest(common.HeatTestCase):
self.man.update_stack,
self.ctx, old_stack.identifier(), template,
params, None, {})
self.assertEqual(ex.exc_info[0], exception.NotSupported)
self.assertEqual(exception.NotSupported, ex.exc_info[0])
self.m.VerifyAll()
@ -1535,7 +1535,7 @@ class StackServiceActionsTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.man.stack_suspend, self.ctx,
stack.identifier())
self.assertEqual(ex.exc_info[0], exception.StackNotFound)
self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll()
def test_stack_resume_nonexist(self):
@ -1547,7 +1547,7 @@ class StackServiceActionsTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.man.stack_resume, self.ctx,
stack.identifier())
self.assertEqual(ex.exc_info[0], exception.StackNotFound)
self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll()
def _mock_thread_start(self, stack_id, func, *args, **kwargs):
@ -1734,14 +1734,14 @@ class StackServiceTest(common.HeatTestCase):
def test_stack_identify_nonexist(self):
ex = self.assertRaises(dispatcher.ExpectedException,
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)
def test_stack_create_existing(self):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.create_stack, self.ctx,
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)
def test_stack_by_name_tenants(self):
@ -1833,7 +1833,7 @@ class StackServiceTest(common.HeatTestCase):
# pointing to an orphaned stack object.
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.assertTrue(result['stack_id'])
events = self.eng.list_events(self.ctx, self.stack.identifier())
@ -2155,7 +2155,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.show_stack,
self.ctx, non_exist_identifier)
self.assertEqual(ex.exc_info[0], exception.StackNotFound)
self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll()
def test_stack_describe_bad_tenant(self):
@ -2174,7 +2174,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.show_stack,
self.ctx, non_exist_identifier)
self.assertEqual(ex.exc_info[0], exception.InvalidTenant)
self.assertEqual(exception.InvalidTenant, ex.exc_info[0])
self.m.VerifyAll()
@ -2337,7 +2337,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.describe_stack_resource,
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()
@ -2351,7 +2351,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.describe_stack_resource,
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()
@ -2366,7 +2366,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.describe_stack_resource,
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()
@ -2436,7 +2436,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.describe_stack_resources,
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')
def test_find_physical_resource(self):
@ -2455,7 +2455,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.find_physical_resource,
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')
def test_stack_resources_list(self):
@ -2531,7 +2531,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.list_stack_resources,
self.ctx, non_exist_identifier)
self.assertEqual(ex.exc_info[0], exception.StackNotFound)
self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll()
@ -2584,7 +2584,7 @@ class StackServiceTest(common.HeatTestCase):
dict(self.stack.identifier()),
'resource_does_not_exist',
test_data)
self.assertEqual(ex.exc_info[0], exception.ResourceNotFound)
self.assertEqual(exception.ResourceNotFound, ex.exc_info[0])
self.m.VerifyAll()
self.stack.delete()
@ -2654,7 +2654,7 @@ class StackServiceTest(common.HeatTestCase):
self.eng.metadata_update,
self.ctx, non_exist_identifier,
'WebServer', test_metadata)
self.assertEqual(ex.exc_info[0], exception.StackNotFound)
self.assertEqual(exception.StackNotFound, ex.exc_info[0])
self.m.VerifyAll()
@stack_context('service_metadata_err_resource_test_stack', False)
@ -2669,7 +2669,7 @@ class StackServiceTest(common.HeatTestCase):
self.eng.metadata_update,
self.ctx, dict(self.stack.identifier()),
'NooServer', test_metadata)
self.assertEqual(ex.exc_info[0], exception.ResourceNotFound)
self.assertEqual(exception.ResourceNotFound, ex.exc_info[0])
self.m.VerifyAll()
@ -2763,7 +2763,7 @@ class StackServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.eng.show_watch,
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
for key in engine_api.WATCH_KEYS:
@ -2923,7 +2923,7 @@ class StackServiceTest(common.HeatTestCase):
self.eng.set_watch_state,
self.ctx, watch_name="nonexistent",
state=state)
self.assertEqual(ex.exc_info[0], exception.WatchRuleNotFound)
self.assertEqual(exception.WatchRuleNotFound, ex.exc_info[0])
self.m.VerifyAll()
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)
ex = self.assertRaises(dispatcher.ExpectedException,
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.parser, 'Stack')
@ -3028,7 +3028,7 @@ class StackServiceTest(common.HeatTestCase):
mock_parser.return_value = mock_parsed_stack
ex = self.assertRaises(dispatcher.ExpectedException,
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')
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,
self.engine.show_software_config,
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_id = config['id']
@ -3152,7 +3152,7 @@ class SoftwareConfigServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.show_software_config,
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,
action='INIT',
@ -3273,7 +3273,7 @@ class SoftwareConfigServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.show_software_deployment,
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()
self.assertIsNotNone(deployment)
@ -3398,7 +3398,7 @@ class SoftwareConfigServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.delete_software_deployment,
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()
self.assertIsNotNone(deployment)
@ -3508,7 +3508,7 @@ class ThreadGroupManagerTest(common.HeatTestCase):
self.tg_mock.add_thread.assert_called_with(
thm._start_with_trace, None,
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):
stack_id = 'test'
@ -3516,7 +3516,7 @@ class ThreadGroupManagerTest(common.HeatTestCase):
thm = service.ThreadGroupManager()
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.cfg_mock.CONF.periodic_interval,
self.f, *self.fargs, **self.fkwargs)
@ -3527,7 +3527,7 @@ class ThreadGroupManagerTest(common.HeatTestCase):
thm = service.ThreadGroupManager()
thm.add_event(stack_id, e1)
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):
stack_id = 'add_events_test'
@ -3536,7 +3536,7 @@ class ThreadGroupManagerTest(common.HeatTestCase):
thm.add_event(stack_id, e1)
thm.add_event(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)
self.assertNotIn(stack_id, thm.events)
@ -3602,7 +3602,7 @@ class SnapshotServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.show_snapshot,
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):
stack = self._create_stack()
@ -3627,7 +3627,7 @@ class SnapshotServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.delete_snapshot,
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):
stack = self._create_stack()
@ -3641,7 +3641,7 @@ class SnapshotServiceTest(common.HeatTestCase):
ex = self.assertRaises(dispatcher.ExpectedException,
self.engine.show_snapshot, self.ctx,
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):
stack = self._create_stack()

View File

@ -1426,7 +1426,7 @@ class KeystoneClientTest(common.HeatTestCase):
self.m.ReplayAll()
ctx = utils.dummy_context()
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()
def test_url_for(self):

View File

@ -431,7 +431,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl = parser.Template(hot_tpl)
stack = parser.Stack(utils.dummy_context(), 'test_stack', tmpl)
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):
"""Test str_replace function."""
@ -827,12 +827,12 @@ class StackTest(test_parser.StackTest):
def test_set_param_id(self):
tmpl = parser.Template(hot_tpl_empty)
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()
stack_identifier = self.stack.identifier()
self.assertEqual(self.stack.parameters['OS::stack_id'], self.stack.id)
self.assertEqual(self.stack.parameters['OS::stack_id'],
stack_identifier.stack_id)
self.assertEqual(self.stack.id, self.stack.parameters['OS::stack_id'])
self.assertEqual(stack_identifier.stack_id,
self.stack.parameters['OS::stack_id'])
self.m.VerifyAll()
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.store()
self.stack.create()
self.assertEqual(self.stack.state,
(parser.Stack.CREATE, parser.Stack.COMPLETE))
self.assertEqual((parser.Stack.CREATE, parser.Stack.COMPLETE),
self.stack.state)
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)
self.stack.update(updated_stack)
self.assertEqual(self.stack.state,
(parser.Stack.UPDATE, parser.Stack.COMPLETE))
self.assertEqual(self.stack['AResource'].properties['Foo'], 'xyz')
self.assertEqual((parser.Stack.UPDATE, parser.Stack.COMPLETE),
self.stack.state)
self.assertEqual('xyz', self.stack['AResource'].properties['Foo'])
self.assertEqual(
self.stack['AResource'].metadata_get()['Bar'], stack_id)
self.assertEqual(stack_id,
self.stack['AResource'].metadata_get()['Bar'])
def test_load_param_id(self):
tmpl = parser.Template(hot_tpl_empty)
self.stack = parser.Stack(self.ctx, 'param_load_id_test', tmpl)
self.stack.store()
stack_identifier = self.stack.identifier()
self.assertEqual(self.stack.parameters['OS::stack_id'],
stack_identifier.stack_id)
self.assertEqual(stack_identifier.stack_id,
self.stack.parameters['OS::stack_id'])
newstack = parser.Stack.load(self.ctx, stack_id=self.stack.id)
self.assertEqual(newstack.parameters['OS::stack_id'],
stack_identifier.stack_id)
self.assertEqual(stack_identifier.stack_id,
newstack.parameters['OS::stack_id'])
def test_update_modify_param_ok_replace(self):
tmpl = {

View File

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

View File

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

View File

@ -101,7 +101,7 @@ Outputs:
stack = self.create_stack(self.test_template)
rsrc = stack['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/' %
rsrc.physical_resource_name())
self.assertTrue(rsrc.FnGetRefId().startswith(arn_prefix))

View File

@ -84,7 +84,7 @@ class NeutronClientPluginTests(NeutronClientPluginTestCase):
'9887157c-d092-40f5-b547-6361915fce7d']
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
sgs_non_uuid = ['security_group_1']
expected_groups = ['0389f747-7785-4757-b7bb-2ab07e4b09c3']

View File

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

View File

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

View File

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

View File

@ -111,44 +111,44 @@ Resources:
assert_min('[a-zA-Z0-9]', random_string, 32)
self.assertRaises(exception.InvalidTemplateAttribute,
secret1.FnGetAtt, 'foo')
self.assertEqual(random_string, secret1.FnGetRefId())
self.assertEqual(secret1.FnGetRefId(), random_string)
secret2 = stack['secret2']
random_string = secret2.FnGetAtt('value')
assert_min('[a-zA-Z0-9]', random_string, 10)
self.assertEqual(random_string, secret2.FnGetRefId())
self.assertEqual(secret2.FnGetRefId(), random_string)
secret3 = stack['secret3']
random_string = secret3.FnGetAtt('value')
assert_min('[0-7]', random_string, 100)
self.assertEqual(random_string, secret3.FnGetRefId())
self.assertEqual(secret3.FnGetRefId(), random_string)
secret4 = stack['secret4']
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('[A-Z]', random_string, 1)
assert_min('[a-z]', random_string, 20)
assert_min('[(),\[\]{}]', random_string, 1)
assert_min('[$_]', random_string, 2)
assert_min('@', random_string, 5)
self.assertEqual(random_string, secret4.FnGetRefId())
self.assertEqual(secret4.FnGetRefId(), random_string)
secret5 = stack['secret5']
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('[A-Z]', random_string, 1)
assert_min('[a-z]', random_string, 20)
self.assertEqual(random_string, secret5.FnGetRefId())
self.assertEqual(secret5.FnGetRefId(), random_string)
secret6 = stack['secret6']
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, 2)
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
secret6.resource_id = None
@ -210,7 +210,7 @@ Resources:
secret = stack['secret']
random_string = secret.FnGetAtt('value')
self.assertEqual(512, len(random_string))
self.assertEqual(random_string, secret.FnGetRefId())
self.assertEqual(secret.FnGetRefId(), random_string)
def test_exceeds_max_length(self):
template_random_string = '''

View File

@ -388,18 +388,18 @@ class ServersTest(common.HeatTestCase):
server.FnGetAtt('addresses')['public'][0]['port'])
self.assertEqual('5678',
server.FnGetAtt('addresses')['public'][1]['port'])
self.assertEqual(
server.FnGetAtt('addresses')['public'][0]['addr'], public_ip)
self.assertEqual(
server.FnGetAtt('networks')['public'][0], public_ip)
self.assertEqual(public_ip,
server.FnGetAtt('addresses')['public'][0]['addr'])
self.assertEqual(public_ip,
server.FnGetAtt('networks')['public'][0])
private_ip = return_server.networks['private'][0]
self.assertEqual('1013',
server.FnGetAtt('addresses')['private'][0]['port'])
self.assertEqual(
server.FnGetAtt('addresses')['private'][0]['addr'], private_ip)
self.assertEqual(
server.FnGetAtt('networks')['private'][0], private_ip)
self.assertEqual(private_ip,
server.FnGetAtt('addresses')['private'][0]['addr'])
self.assertEqual(private_ip,
server.FnGetAtt('networks')['private'][0])
self.assertIn(
server.FnGetAtt('first_address'), (private_ip, public_ip))
@ -2149,7 +2149,7 @@ class ServersTest(common.HeatTestCase):
mox.Replay(get)
self.m.ReplayAll()
self.assertEqual(server._resolve_attribute("accessIPv4"), '')
self.assertEqual('', server._resolve_attribute("accessIPv4"))
self.m.VerifyAll()
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,
orig_tp.id, new_values)
self.assertEqual(updated_tp.id, orig_tp.id)
self.assertEqual(updated_tp.template, new_t)
self.assertEqual(updated_tp.files, new_files)
self.assertEqual(orig_tp.id, updated_tp.id)
self.assertEqual(new_t, updated_tp.template)
self.assertEqual(new_files, updated_tp.files)
class DBAPIUserCredsTest(common.HeatTestCase):

View File

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

View File

@ -677,7 +677,7 @@ class SwiftSignalTest(common.HeatTestCase):
st.create()
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(resource.Resource, 'physical_resource_name')

View File

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

View File

@ -375,7 +375,7 @@ Resources:
t = template_format.parse(self.test_template)
stack = self.parse_stack(t)
scheduler.TaskRunner(stack.create)()
self.assertEqual(stack.state, (stack.CREATE, stack.FAILED))
self.assertEqual((stack.CREATE, stack.FAILED), stack.state)
scheduler.TaskRunner(stack.delete)()
self.m.VerifyAll()
@ -789,7 +789,7 @@ Resources:
self.assertResourceState(attachment, 'the_attachment')
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()
self.m.VerifyAll()

View File

@ -757,7 +757,7 @@ class WaitConditionUpdateTest(common.HeatTestCase):
self.stack.create()
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.UnsetStubs()