Fix the parameter order in method assertEqual.

In assertEqual, the order of parameters should be (expected, observed)

Change-Id: I52770df56ef69e7b79b009a3841d8c3665e7c411
This commit is contained in:
Aaron-DH 2016-01-12 19:07:59 +08:00
parent 4d78a7b34f
commit 63e57b7952
7 changed files with 87 additions and 87 deletions

View File

@ -28,7 +28,7 @@ class TestEnvTemplate(base.TestCase):
resp, body = self.client.get_env_templates_list()
self.assertEqual(0, len(body))
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
@tag('all', 'coverage')
@attr(type='smoke')
@ -39,7 +39,7 @@ class TestEnvTemplate(base.TestCase):
resp, env_template = self.create_env_template('test_env_temp')
self.env_templates.append(env_template)
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertFalse(env_template['is_public'])
self.assertEqual('test_env_temp', env_template['name'])
@ -66,8 +66,8 @@ class TestEnvTemplate(base.TestCase):
resp, env_obtained_template =\
self.client.get_env_template(env_template['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(env_obtained_template['name'], 'test_env_temp')
self.assertEqual(200, resp.status)
self.assertEqual('test_env_temp', env_obtained_template['name'])
@tag('all', 'coverage')
@attr(type='smoke')
@ -75,53 +75,53 @@ class TestEnvTemplate(base.TestCase):
"""Check the creation of an environment template with applications."""
resp, env_template = \
self.create_env_template_with_apps('test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
resp, apps_template = \
self.client.get_apps_in_env_template(env_template['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(len(apps_template), 1)
self.assertEqual(200, resp.status)
self.assertEqual(1, len(apps_template))
@tag('all', 'coverage')
@attr(type='smoke')
def test_create_app_in_env_template(self):
"""Check the creationg of applications in an environment template."""
resp, env_temp = self.create_env_template('test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
resp, apps = self.client.get_apps_in_env_template(env_temp['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(len(apps), 0)
self.assertEqual(200, resp.status)
self.assertEqual(0, len(apps))
resp, apps = self.client.create_app_in_env_template(env_temp['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
resp, apps = self.client.get_apps_in_env_template(env_temp['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(len(apps), 1)
self.assertEqual(200, resp.status)
self.assertEqual(1, len(apps))
@tag('all', 'coverage')
@attr(type='smoke')
def test_delete_app_in_env_template(self):
"""Check the deletion of applications in an environmente template."""
resp, env_temp = self.create_env_template_with_apps('test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
resp, apps = self.client.get_apps_in_env_template(env_temp['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(len(apps), 1)
self.assertEqual(200, resp.status)
self.assertEqual(1, len(apps))
resp = self.client.delete_app_in_env_template(env_temp['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
resp, apps = self.client.get_apps_in_env_template(env_temp['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(len(apps), 0)
self.assertEqual(200, resp.status)
self.assertEqual(0, len(apps))
@tag('all', 'coverage')
@attr(type='smoke')
def test_create_public_env_template(self):
"""Check the creation of a public environment template."""
resp, env_temp = self.create_public_env_template('test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
resp, env = self.client.get_env_template(env_temp['id'])
self.assertEqual(resp.status, 200)
self.assertTrue(env['is_public'], 200)
self.assertEqual(200, resp.status)
self.assertTrue(env['is_public'])
@tag('all', 'coverage')
@attr(type='smoke')
@ -129,11 +129,11 @@ class TestEnvTemplate(base.TestCase):
"""Check the creation of a public environment template."""
resp, env_template = self.\
create_public_env_template('test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
resp, cloned_templ = self.clone_env_template(env_template['id'],
'cloned_template')
self.assertEqual(resp.status, 200)
self.assertTrue(cloned_templ['name'], 'cloned_template')
self.assertEqual(200, resp.status)
self.assertEqual('cloned_template', cloned_templ['name'])
@tag('all', 'coverage')
@attr(type='smoke')
@ -141,7 +141,7 @@ class TestEnvTemplate(base.TestCase):
"""Check the creation of a public environment template."""
resp, env_template = self.\
create_env_template('test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertRaises(exceptions.Forbidden,
self.clone_env_template,
env_template['id'], 'cloned_template')
@ -152,15 +152,15 @@ class TestEnvTemplate(base.TestCase):
"""Check the deletion of applications in an environmente template."""
resp, public_env_template = \
self.create_public_env_template('public_test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(public_env_template['is_public'], True)
self.assertEqual(200, resp.status)
self.assertTrue(public_env_template['is_public'])
resp, private_env_template = \
self.create_env_template('private_test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(private_env_template['is_public'], False)
self.assertEqual(200, resp.status)
self.assertFalse(private_env_template['is_public'])
resp, public_envs = self.client.get_public_env_templates_list()
self.assertEqual(resp.status, 200)
self.assertEqual(len(public_envs), 1)
self.assertEqual(200, resp.status)
self.assertEqual(1, len(public_envs))
@tag('all', 'coverage')
@attr(type='smoke')
@ -168,15 +168,15 @@ class TestEnvTemplate(base.TestCase):
"""Check the deletion of applications in an environmente template."""
resp, public_env_template = \
self.create_public_env_template('public_test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(public_env_template['is_public'], True)
self.assertEqual(200, resp.status)
self.assertTrue(public_env_template['is_public'])
resp, private_env_template = \
self.create_env_template('private_test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(private_env_template['is_public'], False)
self.assertEqual(200, resp.status)
self.assertFalse(private_env_template['is_public'])
resp, private_envs = self.client.get_private_env_templates_list()
self.assertEqual(resp.status, 200)
self.assertEqual(len(private_envs), 1)
self.assertEqual(200, resp.status)
self.assertEqual(1, len(private_envs))
@tag('all', 'coverage')
@attr(type='smoke')
@ -184,15 +184,15 @@ class TestEnvTemplate(base.TestCase):
"""Check the deletion of applications in an environmente template."""
resp, public_env_template = \
self.create_public_env_template('public_test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(public_env_template['is_public'], True)
self.assertEqual(200, resp.status)
self.assertTrue(public_env_template['is_public'])
resp, private_env_template = \
self.create_env_template('private_test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(private_env_template['is_public'], False)
self.assertEqual(200, resp.status)
self.assertFalse(private_env_template['is_public'])
resp, envs_templates = self.client.get_env_templates_list()
self.assertEqual(resp.status, 200)
self.assertEqual(len(envs_templates), 2)
self.assertEqual(200, resp.status)
self.assertEqual(2, len(envs_templates))
@tag('all', 'coverage')
@attr(type='smoke')
@ -200,11 +200,11 @@ class TestEnvTemplate(base.TestCase):
"""Check the creation of an environment from a template."""
resp, env_template = \
self.create_env_template_with_apps('test_env_temp')
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
resp, env = self.create_env_from_template(env_template['id'],
"env")
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertIsNotNone(env)
@tag('all', 'coverage')

View File

@ -27,7 +27,7 @@ class TestEnvironments(base.TestCase):
resp, body = self.client.get_environments_list()
self.assertIn('environments', body)
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
@tag('all', 'coverage')
@attr(type='smoke')
@ -37,7 +37,7 @@ class TestEnvironments(base.TestCase):
resp, env = self.client.create_environment('test')
self.environments.append(env)
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertEqual('test', env['name'])
environments_list = self.client.get_environments_list()[1]
@ -63,7 +63,7 @@ class TestEnvironments(base.TestCase):
resp, env = self.client.create_environment(unicode_name)
self.environments.append(env)
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertEqual(unicode_name, env['name'])
environments_list = self.client.get_environments_list()[1]
@ -87,8 +87,8 @@ class TestEnvironments(base.TestCase):
resp, environment = self.client.get_environment(env['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(environment['name'], 'test')
self.assertEqual(200, resp.status)
self.assertEqual('test', environment['name'])
@tag('all', 'coverage')
@attr(type='smoke')
@ -97,8 +97,8 @@ class TestEnvironments(base.TestCase):
resp, environment = self.client.update_environment(env['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(environment['name'], 'changed-environment-name')
self.assertEqual(200, resp.status)
self.assertEqual('changed-environment-name', environment['name'])
@tag('all', 'coverage')
@attr(type='negative')

View File

@ -31,7 +31,7 @@ class TestServices(base.TestCase):
resp, services_list = self.client.get_services_list(env['id'],
sess['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertIsInstance(services_list, list)
@tag('all', 'coverage')
@ -88,7 +88,7 @@ class TestServices(base.TestCase):
services_list_ = self.client.get_services_list(env['id'],
sess['id'])[1]
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertEqual(len(services_list) + 1, len(services_list_))
resp = self.client.delete_service(env['id'],
@ -98,7 +98,7 @@ class TestServices(base.TestCase):
services_list_ = self.client.get_services_list(env['id'],
sess['id'])[1]
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertEqual(len(services_list), len(services_list_))
@tag('all', 'coverage')
@ -185,7 +185,7 @@ class TestServices(base.TestCase):
sess['id'],
service['?']['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertEqual(service, service_)
@tag('all', 'coverage')
@ -208,7 +208,7 @@ class TestServices(base.TestCase):
def test_get_services_without_sess_id(self):
env = self.create_environment('test')
resp, body = self.client.get_services_list(env['id'], None)
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertEqual([], body)

View File

@ -29,7 +29,7 @@ class TestSessions(base.TestCase):
resp, sess = self.client.create_session(env['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
self.assertEqual(env['id'], sess['environment_id'])
@tag('all', 'coverage')
@ -48,7 +48,7 @@ class TestSessions(base.TestCase):
resp = self.client.delete_session(env['id'], sess['id'])[0]
self.assertEqual(resp.status, 200)
self.assertEqual(200, resp.status)
@tag('all', 'coverage')
@attr(type='negative')
@ -71,8 +71,8 @@ class TestSessions(base.TestCase):
resp, session = self.client.get_session(env['id'], sess['id'])
self.assertEqual(resp.status, 200)
self.assertEqual(session, sess)
self.assertEqual(200, resp.status)
self.assertEqual(sess, session)
@tag('all', 'coverage')
@attr(type='negative')

View File

@ -191,11 +191,11 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
res = req.get_response(self.api)
self.assertEqual(200, res.status_code)
self.assertEqual(len(res.json['packages']), 1)
self.assertEqual(1, len(res.json['packages']))
found_package = res.json['packages'][0]
self.assertEqual(found_package['id'], expected_package.id)
self.assertEqual(expected_package.id, found_package['id'])
def test_packages_filter_by_name(self):
"""GET /catalog/packages with parameter "name" returns packages
@ -220,15 +220,15 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
res_pkgname1 = req_pkgname1.get_response(self.api)
self.assertEqual(200, res_pkgname1.status_code)
self.assertEqual(len(res_pkgname1.json['packages']), 1)
self.assertEqual(res_pkgname1.json['packages'][0]['name'],
expected_pkg1.name)
self.assertEqual(1, len(res_pkgname1.json['packages']))
self.assertEqual(expected_pkg1.name,
res_pkgname1.json['packages'][0]['name'])
res_pkgname2 = req_pkgname2.get_response(self.api)
self.assertEqual(200, res_pkgname2.status_code)
self.assertEqual(len(res_pkgname2.json['packages']), 1)
self.assertEqual(res_pkgname2.json['packages'][0]['name'],
expected_pkg2.name)
self.assertEqual(1, len(res_pkgname2.json['packages']))
self.assertEqual(expected_pkg2.name,
res_pkgname2.json['packages'][0]['name'])
def test_packages_filter_by_type(self):
"""GET /catalog/packages with parameter "type" returns packages
@ -257,24 +257,24 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
res_lib = req_lib.get_response(self.api)
self.assertEqual(200, res_lib.status_code)
self.assertEqual(len(res_lib.json['packages']), 2)
self.assertEqual(2, len(res_lib.json['packages']))
self.assertEqual(res_lib.json['packages'][0]['type'], 'Library')
self.assertEqual(res_lib.json['packages'][0]['name'],
excepted_pkg1.name)
self.assertEqual('Library', res_lib.json['packages'][0]['type'])
self.assertEqual(excepted_pkg1.name,
res_lib.json['packages'][0]['name'])
self.assertEqual(res_lib.json['packages'][1]['type'], 'Library')
self.assertEqual(res_lib.json['packages'][1]['name'],
excepted_pkg2.name)
self.assertEqual('Library', res_lib.json['packages'][1]['type'])
self.assertEqual(excepted_pkg2.name,
res_lib.json['packages'][1]['name'])
res_app = req_app.get_response(self.api)
self.assertEqual(200, res_app.status_code)
self.assertEqual(len(res_app.json['packages']), 1)
self.assertEqual(1, len(res_app.json['packages']))
self.assertEqual(res_app.json['packages'][0]['type'], 'Application')
self.assertEqual(res_app.json['packages'][0]['name'],
excepted_pkg3.name)
self.assertEqual('Application', res_app.json['packages'][0]['type'])
self.assertEqual(excepted_pkg3.name,
res_app.json['packages'][0]['name'])
def test_packages(self):
self._set_policy_rules(

View File

@ -35,12 +35,12 @@ class TraverseHelperTests(base.MuranoTestCase):
def test_attribute_get(self):
source = {'attr': True}
value = utils.TraverseHelper.get('/attr', source)
self.assertEqual(True, value)
self.assertTrue(value)
def test_nested_attribute_get(self):
source = {'obj': {'attr': True}}
value = utils.TraverseHelper.get('/obj/attr', source)
self.assertEqual(True, value)
self.assertTrue(value)
def test_list_item_attribute_get(self):
source = {'obj': [
@ -62,19 +62,19 @@ class TraverseHelperTests(base.MuranoTestCase):
source = {'attr': True}
utils.TraverseHelper.update('/newAttr', False, source)
value = utils.TraverseHelper.get('/newAttr', source)
self.assertEqual(False, value)
self.assertFalse(value)
def test_attribute_update(self):
source = {'attr': True}
utils.TraverseHelper.update('/attr', False, source)
value = utils.TraverseHelper.get('/attr', source)
self.assertEqual(False, value)
self.assertFalse(value)
def test_nested_attribute_update(self):
source = {'obj': {'attr': True}}
utils.TraverseHelper.update('/obj/attr', False, source)
value = utils.TraverseHelper.get('/obj/attr', source)
self.assertEqual(False, value)
self.assertFalse(value)
def test_adding_item_to_list(self):
source = {'attr': [1, 2, 3]}

View File

@ -108,7 +108,7 @@ class TestCongressRules(unittest.TestCase):
def test_empty_model(self):
congress_rules = congress.CongressRulesManager()
rules = congress_rules.convert(None)
self.assertTrue(len(rules) == 0)
self.assertEqual(0, len(rules))
def test_convert_simple_app(self):
rules_str = self._create_and_check_rules_str('model')