Removing sorted() function from assertEqual()
Removing unnecessary sorted() function from assertEqual() function calls in functions used for sorting and pagination testing Using sorted() breaks sorting tests objective which is to test sorting. This is causing every unit test using this functions (_test_list_with_sort, _test_list_with_pagination, _test_list_with_pagination_reverse) for sorting tests to always succeed Switched the parameters for assertEqual() function within the fixed code to meet its signature - assertEqual(self, expected, observed, message='') Test neutron.tests.unit.vmware.vshield.test_lbaas_plugin.TestLoadbalancerPlugin.test_list_vips was succeeding because of this bug, although it should fail. It failed after the bug was fix. Test was fixed. Change-Id: Ia36b81d9a7fd32cae3b567ac1899b56481eb62ce Closes-Bug: #1355251
This commit is contained in:
parent
3c5ce011f2
commit
c9e13eacf0
@ -582,8 +582,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
||||
resource = resource.replace('-', '_')
|
||||
resources = resources.replace('-', '_')
|
||||
expected_res = [item[resource]['id'] for item in items]
|
||||
self.assertEqual(sorted([n['id'] for n in res[resources]]),
|
||||
sorted(expected_res))
|
||||
self.assertEqual(expected_res, [n['id'] for n in res[resources]])
|
||||
|
||||
def _test_list_with_pagination(self, resource, items, sort,
|
||||
limit, expected_page_num,
|
||||
@ -616,10 +615,9 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
||||
'', content_type)
|
||||
self.assertEqual(len(res[resources]),
|
||||
limit)
|
||||
self.assertEqual(page_num, expected_page_num)
|
||||
self.assertEqual(sorted([n[verify_key] for n in items_res]),
|
||||
sorted([item[resource][verify_key]
|
||||
for item in items]))
|
||||
self.assertEqual(expected_page_num, page_num)
|
||||
self.assertEqual([item[resource][verify_key] for item in items],
|
||||
[n[verify_key] for n in items_res])
|
||||
|
||||
def _test_list_with_pagination_reverse(self, resource, items, sort,
|
||||
limit, expected_page_num,
|
||||
@ -655,11 +653,10 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
||||
'', content_type)
|
||||
self.assertEqual(len(res[resources]),
|
||||
limit)
|
||||
self.assertEqual(page_num, expected_page_num)
|
||||
self.assertEqual(expected_page_num, page_num)
|
||||
expected_res = [item[resource]['id'] for item in items]
|
||||
expected_res.reverse()
|
||||
self.assertEqual(sorted([n['id'] for n in item_res]),
|
||||
sorted(expected_res))
|
||||
self.assertEqual(expected_res, [n['id'] for n in item_res])
|
||||
|
||||
|
||||
class TestBasicGet(NeutronDbPluginV2TestCase):
|
||||
|
@ -361,7 +361,7 @@ class TestLoadbalancerPlugin(
|
||||
) as (vip1, vip2, vip3):
|
||||
self._test_list_with_sort(
|
||||
'vip',
|
||||
(vip1, vip3, vip2),
|
||||
(vip1, vip2, vip3),
|
||||
[('protocol_port', 'asc'), ('name', 'desc')]
|
||||
)
|
||||
req = self.new_list_request('vips')
|
||||
|
Loading…
Reference in New Issue
Block a user