Merge "Use assertEqual instead of assertItemsEqual"

This commit is contained in:
Zuul 2020-07-20 18:24:36 +00:00 committed by Gerrit Code Review
commit 4ee6a30a11
4 changed files with 12 additions and 10 deletions

View File

@ -5347,7 +5347,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
result = self.client.get_aggregate_disk_types( result = self.client.get_aggregate_disk_types(
fake.SHARE_AGGREGATE_NAME) fake.SHARE_AGGREGATE_NAME)
self.assertItemsEqual(expected, result) self.assertEqual(sorted(expected), sorted(result))
mock_get_aggregate_disk_types.assert_called_once_with( mock_get_aggregate_disk_types.assert_called_once_with(
fake.SHARE_AGGREGATE_NAME) fake.SHARE_AGGREGATE_NAME)
@ -5375,7 +5375,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
fake.SHARE_AGGREGATE_NAME) fake.SHARE_AGGREGATE_NAME)
self.assertIsInstance(result, list) self.assertIsInstance(result, list)
self.assertItemsEqual(['SATA', 'SSD'], result) self.assertEqual(sorted(['SATA', 'SSD']), sorted(result))
mock_get_aggregate_disk_types.assert_has_calls([ mock_get_aggregate_disk_types.assert_has_calls([
mock.call(fake.SHARE_AGGREGATE_NAME), mock.call(fake.SHARE_AGGREGATE_NAME),
mock.call(fake.SHARE_AGGREGATE_NAME, shared=True), mock.call(fake.SHARE_AGGREGATE_NAME, shared=True),

View File

@ -372,7 +372,7 @@ class PerformanceLibraryTestCase(test.TestCase):
self.fake_volumes, self.fake_aggregates) self.fake_volumes, self.fake_aggregates)
expected_aggregate_names = ['aggr1', 'aggr2', 'aggr3'] expected_aggregate_names = ['aggr1', 'aggr2', 'aggr3']
self.assertItemsEqual(expected_aggregate_names, result) self.assertEqual(sorted(expected_aggregate_names), sorted(result))
def test_get_nodes_for_aggregates(self): def test_get_nodes_for_aggregates(self):
@ -390,7 +390,8 @@ class PerformanceLibraryTestCase(test.TestCase):
expected_node_names = ['node1', 'node2'] expected_node_names = ['node1', 'node2']
expected_aggr_node_map = dict(zip(aggregate_names, aggregate_nodes)) expected_aggr_node_map = dict(zip(aggregate_names, aggregate_nodes))
self.assertItemsEqual(expected_node_names, result_node_names) self.assertEqual(sorted(expected_node_names),
sorted(result_node_names))
self.assertEqual(expected_aggr_node_map, result_aggr_node_map) self.assertEqual(expected_aggr_node_map, result_aggr_node_map)
mock_get_node_for_aggregate.assert_has_calls([ mock_get_node_for_aggregate.assert_has_calls([
mock.call('aggr1'), mock.call('aggr2'), mock.call('aggr3')]) mock.call('aggr1'), mock.call('aggr2'), mock.call('aggr3')])

View File

@ -170,7 +170,7 @@ class ShareTypesTestCase(test.TestCase):
'share_type_get_all', 'share_type_get_all',
mock.Mock(return_value=copy.deepcopy(share_type))) mock.Mock(return_value=copy.deepcopy(share_type)))
returned_type = share_types.get_all_types(self.context) returned_type = share_types.get_all_types(self.context)
self.assertItemsEqual(share_type, returned_type) self.assertEqual(sorted(share_type), sorted(returned_type))
def test_get_all_types_search(self): def test_get_all_types_search(self):
share_type = self.fake_type_w_extra share_type = self.fake_type_w_extra
@ -183,7 +183,7 @@ class ShareTypesTestCase(test.TestCase):
db.share_type_get_all.assert_called_once_with( db.share_type_get_all.assert_called_once_with(
mock.ANY, 0, filters={'is_public': True}) mock.ANY, 0, filters={'is_public': True})
self.assertItemsEqual(share_type, returned_type) self.assertEqual(sorted(share_type), sorted(returned_type))
search_filter = {'extra_specs': {'gold': 'False'}} search_filter = {'extra_specs': {'gold': 'False'}}
expected_types = {} expected_types = {}
returned_types = share_types.get_all_types(self.context, returned_types = share_types.get_all_types(self.context,
@ -194,7 +194,7 @@ class ShareTypesTestCase(test.TestCase):
search_filter = {'extra_specs': {'gold': 'True'}} search_filter = {'extra_specs': {'gold': 'True'}}
returned_type = share_types.get_all_types(self.context, returned_type = share_types.get_all_types(self.context,
search_opts=search_filter) search_opts=search_filter)
self.assertItemsEqual(share_type, returned_type) self.assertEqual(sorted(share_type), sorted(returned_type))
@ddt.data("nova", "supernova,nova", "supernova", @ddt.data("nova", "supernova,nova", "supernova",
"nova,hypernova,supernova") "nova,hypernova,supernova")
@ -268,7 +268,8 @@ class ShareTypesTestCase(test.TestCase):
expected_return_types = (['gold', 'silver', 'default'] expected_return_types = (['gold', 'silver', 'default']
if len(search_azs.split(',')) < 3 if len(search_azs.split(',')) < 3
else ['gold', 'default']) else ['gold', 'default'])
self.assertItemsEqual(expected_return_types, returned_types) self.assertEqual(sorted(expected_return_types),
sorted(returned_types))
def test_get_share_type_extra_specs(self): def test_get_share_type_extra_specs(self):
share_type = self.fake_type_w_extra['test_with_extra'] share_type = self.fake_type_w_extra['test_with_extra']

View File

@ -98,7 +98,7 @@ class ShareGroupTypesTestCase(test.TestCase):
returned_type = share_group_types.get_all(self.context) returned_type = share_group_types.get_all(self.context)
self.assertItemsEqual(share_group_type, returned_type) self.assertEqual(sorted(share_group_type), sorted(returned_type))
def test_get_all_types_search(self): def test_get_all_types_search(self):
share_group_type = self.fake_type_w_extra share_group_type = self.fake_type_w_extra
@ -112,7 +112,7 @@ class ShareGroupTypesTestCase(test.TestCase):
db.share_group_type_get_all.assert_called_once_with( db.share_group_type_get_all.assert_called_once_with(
mock.ANY, 0, filters={'is_public': True}) mock.ANY, 0, filters={'is_public': True})
self.assertItemsEqual(share_group_type, returned_type) self.assertEqual(sorted(share_group_type), sorted(returned_type))
search_filter = {"group_specs": {"gold": "False"}} search_filter = {"group_specs": {"gold": "False"}}
returned_type = share_group_types.get_all( returned_type = share_group_types.get_all(
self.context, search_opts=search_filter) self.context, search_opts=search_filter)