Merge "Fix order of arguments in assertEqual"

This commit is contained in:
Jenkins 2016-06-27 03:53:34 +00:00 committed by Gerrit Code Review
commit 306b7c77a3
3 changed files with 12 additions and 12 deletions

View File

@ -38,26 +38,26 @@ class TestAPIBase(test_base.BaseTestCase):
expected_value = {
'test': 'test_value',
}
self.assertEqual(test_api.__json__(), expected_value)
self.assertEqual(expected_value, test_api.__json__())
def test_no_field_assigned(self):
test_api = self.test_api_cls()
expected_value = {}
self.assertEqual(test_api.__json__(), expected_value)
self.assertEqual(expected_value, test_api.__json__())
def test_assign_field_in_constructor(self):
test_api = self.test_api_cls(test='test_value')
expected_value = {
'test': 'test_value',
}
self.assertEqual(test_api.__json__(), expected_value)
self.assertEqual(expected_value, test_api.__json__())
def test_assign_nonexist_field(self):
test_api = self.test_api_cls()
test_api.nonexist = 'test_value'
expected_value = {}
self.assertEqual(test_api.__json__(), expected_value)
self.assertEqual(expected_value, test_api.__json__())
def test_assign_multiple_fields(self):
class TestAPI(base.APIBase):
@ -81,5 +81,5 @@ class TestAPIBase(test_base.BaseTestCase):
])
actual_value = collections.OrderedDict(
sorted(test_api.as_dict().items()))
self.assertEqual(six.text_type(actual_value),
six.text_type(expected_value))
self.assertEqual(six.text_type(expected_value),
six.text_type(actual_value))

View File

@ -29,5 +29,5 @@ class TestLink(test_base.BaseTestCase):
('href', 'http://localhost:8080/v1/'),
('rel', 'self')
])
self.assertEqual(six.text_type(ordered_link),
six.text_type(expected_value))
self.assertEqual(six.text_type(expected_value),
six.text_type(ordered_link))

View File

@ -33,12 +33,12 @@ class TestTypes(test_base.BaseTestCase):
value = TestAPI(test='test_value')
value = test_type.validate(value)
self.assertIsInstance(value, TestAPI)
self.assertEqual(value.as_dict(), {'test': 'test_value'})
self.assertEqual({'test': 'test_value'}, value.as_dict())
test_type = types.Custom(TestAPI)
value = test_type.validate({'test': 'test_value'})
self.assertIsInstance(value, TestAPI)
self.assertEqual(value.as_dict(), {'test': 'test_value'})
self.assertEqual({'test': 'test_value'}, value.as_dict())
self.assertRaises(
exception.InvalidValue,
@ -47,7 +47,7 @@ class TestTypes(test_base.BaseTestCase):
def test_list_with_text_type(self):
list_type = types.List(types.Text)
value = list_type.validate(['test1', 'test2'])
self.assertEqual(value, ['test1', 'test2'])
self.assertEqual(['test1', 'test2'], value)
self.assertRaises(
exception.InvalidValue,
@ -66,4 +66,4 @@ class TestTypes(test_base.BaseTestCase):
value = list_type.validate(value)
self.assertIsInstance(value, list)
self.assertIsInstance(value[0], TestAPI)
self.assertEqual(value[0].as_dict(), {'test': 'test_value'})
self.assertEqual({'test': 'test_value'}, value[0].as_dict())