Fix assertEqual arguments order(catalog, cert_setup, etc)

assertEqual method's arguments should be in
('expected', 'actual') order.

Change-Id: Id591629a10e6e82c4eb607a9994071f16dd80d8b
Partial-Bug: #1277104
This commit is contained in:
Haiwei Xu 2014-02-26 00:17:00 +09:00
parent d8c0c81d68
commit e505b49181
8 changed files with 37 additions and 31 deletions

View File

@ -30,3 +30,9 @@ Use the common logging module, and ensure you ``getLogger``::
LOG = log.getLogger(__name__)
LOG.debug('Foobar')
AssertEqual argument order
--------------------------
assertEqual method's arguments should be in ('expected', 'actual') order.

View File

@ -94,7 +94,7 @@ class V2CatalogTestCase(rest.RestfulTestCase):
def test_endpoint_create_with_empty_adminurl(self):
req_body, response = self._endpoint_create(adminurl='')
self.assertEqual(req_body['endpoint']['adminurl'], '')
self.assertEqual('', req_body['endpoint']['adminurl'])
self.assertNotIn("adminurl", response.result['endpoint'])
def test_endpoint_create_with_null_internalurl(self):
@ -104,7 +104,7 @@ class V2CatalogTestCase(rest.RestfulTestCase):
def test_endpoint_create_with_empty_internalurl(self):
req_body, response = self._endpoint_create(internalurl='')
self.assertEqual(req_body['endpoint']['internalurl'], '')
self.assertEqual('', req_body['endpoint']['internalurl'])
self.assertNotIn("internalurl", response.result['endpoint'])
def test_endpoint_create_with_null_publicurl(self):

View File

@ -115,10 +115,10 @@ class CertSetupTestCase(rest.RestfulTestCase):
method='GET', expected_status=200)
with open(CONF.signing.certfile) as f:
self.assertEqual(signing_resp.text, f.read())
self.assertEqual(f.read(), signing_resp.text)
with open(CONF.signing.ca_certs) as f:
self.assertEqual(cacert_resp.text, f.read())
self.assertEqual(f.read(), cacert_resp.text)
# NOTE(jamielennox): This is weird behaviour that we need to enforce.
# It doesn't matter what you ask for it's always going to give text
@ -131,7 +131,7 @@ class CertSetupTestCase(rest.RestfulTestCase):
expected_status=200,
headers=headers)
self.assertEqual(resp.content_type, 'text/html')
self.assertEqual('text/html', resp.content_type)
def test_failure(self):
for path in ['/v2.0/certificates/signing', '/v2.0/certificates/ca']:

View File

@ -62,8 +62,8 @@ class DeprecatedTestCase(tests.TestCase):
# Options in [sql] were moved to [database] in Icehouse for the change
# to use oslo-incubator's db.sqlalchemy.sessions.
self.assertEqual(CONF.database.connection, 'sqlite://deprecated')
self.assertEqual(CONF.database.idle_timeout, 54321)
self.assertEqual('sqlite://deprecated', CONF.database.connection)
self.assertEqual(54321, CONF.database.idle_timeout)
class DeprecatedOverrideTestCase(tests.TestCase):
@ -78,5 +78,5 @@ class DeprecatedOverrideTestCase(tests.TestCase):
# Options in [sql] were moved to [database] in Icehouse for the change
# to use oslo-incubator's db.sqlalchemy.sessions.
self.assertEqual(CONF.database.connection, 'sqlite://new')
self.assertEqual(CONF.database.idle_timeout, 65432)
self.assertEqual('sqlite://new', CONF.database.connection)
self.assertEqual(65432, CONF.database.idle_timeout)

View File

@ -33,7 +33,7 @@ class TestSimpleCert(BaseTestCase):
headers={'Accept': content_type},
expected_status=200)
self.assertEqual(response.content_type.lower(), content_type)
self.assertEqual(content_type, response.content_type.lower())
self.assertIn('---BEGIN', response.body)
return response

View File

@ -24,39 +24,39 @@ class ListHintsTests(test.TestCase):
hints = driver_hints.Hints()
hints.add_filter('t1', 'data1')
hints.add_filter('t2', 'data2')
self.assertEqual(len(hints.filters()), 2)
self.assertEqual(2, len(hints.filters()))
filter = hints.get_exact_filter_by_name('t1')
self.assertEqual(filter['name'], 't1')
self.assertEqual(filter['value'], 'data1')
self.assertEqual(filter['comparator'], 'equals')
self.assertEqual(filter['case_sensitive'], False)
self.assertEqual('t1', filter['name'])
self.assertEqual('data1', filter['value'])
self.assertEqual('equals', filter['comparator'])
self.assertEqual(False, filter['case_sensitive'])
hints.remove(filter)
filter_count = 0
for filter in hints.filters():
filter_count += 1
self.assertEqual(filter['name'], 't2')
self.assertEqual(filter_count, 1)
self.assertEqual('t2', filter['name'])
self.assertEqual(1, filter_count)
def test_multiple_creates(self):
hints = driver_hints.Hints()
hints.add_filter('t1', 'data1')
hints.add_filter('t2', 'data2')
self.assertEqual(len(hints.filters()), 2)
self.assertEqual(2, len(hints.filters()))
hints2 = driver_hints.Hints()
hints2.add_filter('t4', 'data1')
hints2.add_filter('t5', 'data2')
self.assertEqual(len(hints.filters()), 2)
self.assertEqual(2, len(hints.filters()))
def test_limits(self):
hints = driver_hints.Hints()
self.assertIsNone(hints.get_limit())
hints.set_limit(10)
self.assertEqual(hints.get_limit()['limit'], 10)
self.assertEqual(10, hints.get_limit()['limit'])
self.assertFalse(hints.get_limit()['truncated'])
hints.set_limit(11)
self.assertEqual(hints.get_limit()['limit'], 11)
self.assertEqual(11, hints.get_limit()['limit'])
self.assertFalse(hints.get_limit()['truncated'])
hints.set_limit(10, truncated=True)
self.assertEqual(hints.get_limit()['limit'], 10)
self.assertEqual(10, hints.get_limit()['limit'])
self.assertTrue(hints.get_limit()['truncated'])

View File

@ -29,8 +29,8 @@ CONF = config.CONF
class ExceptionTestCase(tests.TestCase):
def assertValidJsonRendering(self, e):
resp = wsgi.render_exception(e)
self.assertEqual(resp.status_int, e.code)
self.assertEqual(resp.status, '%s %s' % (e.code, e.title))
self.assertEqual(e.code, resp.status_int)
self.assertEqual('%s %s' % (e.code, e.title), resp.status)
j = jsonutils.loads(resp.body)
self.assertIsNotNone(j.get('error'))
@ -81,7 +81,7 @@ class ExceptionTestCase(tests.TestCase):
e = exception.Error(message)
try:
self.assertEqual(six.text_type(e), message)
self.assertEqual(message, six.text_type(e))
except UnicodeEncodeError:
self.fail("unicode error message not supported")

View File

@ -144,14 +144,14 @@ class TestDependencyInjection(tests.BaseTestCase):
# dependencies should be naturally inherited
self.assertEqual(
ParentConsumer._dependencies,
set(['first_api']))
set(['first_api']),
ParentConsumer._dependencies)
self.assertEqual(
ChildConsumer._dependencies,
set(['first_api', 'second_api']))
set(['first_api', 'second_api']),
ChildConsumer._dependencies)
self.assertEqual(
consumer._dependencies,
set(['first_api', 'second_api']))
set(['first_api', 'second_api']),
consumer._dependencies)
# the expected dependencies should be available to the consumer
self.assertIs(consumer.first_api, first_api)