Fix argument order for assertEqual to (expected, observed)

assertEqual expects that the arguments provided to it should be
(expected, observed). If a particluar order is kept as a convention,
then it helps to provide a cleaner message to the developer if Unit
Tests fail. The following patch fixes this issue.

Change-Id: I5209e5889cfe62c66dc675c00e3ccaf22410f637
Partial-Bug: #1259292
changes/17/338717/1
hongzhezheng 6 years ago
parent b128a4d2e1
commit 86d91e4e4e
  1. 12
      barbicanclient/tests/test_client.py
  2. 4
      barbicanclient/tests/test_containers.py
  3. 2
      functionaltests/client/v1/functional/test_acl.py

@ -151,13 +151,13 @@ class WhenTestingClientGet(TestClient):
def test_get_uses_href_as_is(self):
self.httpclient.get(self.href)
self.assertEqual(self.get_mock.last_request.url, self.href)
self.assertEqual(self.href, self.get_mock.last_request.url)
def test_get_passes_params(self):
params = {'test': 'test1'}
self.httpclient.get(self.href, params=params)
self.assertEqual(self.get_mock.last_request.url.split('?')[0],
self.href)
self.assertEqual(self.href,
self.get_mock.last_request.url.split('?')[0])
self.assertEqual(['test1'], self.get_mock.last_request.qs['test'])
def test_get_includes_accept_header_of_application_json(self):
@ -179,7 +179,7 @@ class WhenTestingClientGet(TestClient):
def test_get_raw_uses_href_as_is(self):
self.httpclient._get_raw(self.href, headers=self.headers)
self.assertEqual(self.get_mock.last_request.url, self.href)
self.assertEqual(self.href, self.get_mock.last_request.url)
def test_get_raw_passes_headers(self):
self.httpclient._get_raw(self.href, headers={'test': 'test'})
@ -263,14 +263,14 @@ class WhenTestingGetErrorMessage(TestClient):
resp.json.side_effect = ValueError()
resp.content = content = 'content'
msg = self.httpclient._get_error_message(resp)
self.assertEqual(msg, content)
self.assertEqual(content, msg)
def test_gets_error_message_from_description_in_json(self):
resp = mock.MagicMock()
resp.json.return_value = {'title': 'test_text',
'description': 'oopsie'}
msg = self.httpclient._get_error_message(resp)
self.assertEqual(msg, 'test_text: oopsie')
self.assertEqual('test_text: oopsie', msg)
class BaseEntityResource(testtools.TestCase):

@ -283,8 +283,8 @@ class WhenTestingContainers(test_client.BaseEntityResource):
secrets=self.container.generic_secrets
)
self.assertEqual(container.secret_refs,
self.container.generic_secret_refs)
self.assertEqual(self.container.generic_secret_refs,
container.secret_refs)
def test_should_reload_attributes_after_store(self):
data = {'container_ref': self.entity_href}

@ -291,7 +291,7 @@ class ACLsTestCase(BaseACLsTestCase):
entity.remove
)
self.assertEqual(e.status_code, 404)
self.assertEqual(404, e.status_code)
@utils.parameterized_dataset(ACL_SUBMIT_DATA_POSITIVE)
@testcase.attr('positive')

Loading…
Cancel
Save