Use assertCountEqual instead of assertItemsEqual
The assertItemsEqual method has been removed in Python 3.3 [1] but it was kept alive by unittest2, imported by testtools. To prevent mayhem and despair caused by testtools removing unittest2 from its requirements in the near future, we switch to assertCountEqual. [1] https://bugs.python.org/issue17866 Change-Id: I614bcedc9981370fb54cfe3da997a3d52484c07f
This commit is contained in:
parent
9742240daf
commit
ca1c1b87af
@ -114,7 +114,7 @@ class TestListAllocations(test_api_base.BaseApiTest):
|
||||
'/allocations/%s?fields=%s' % (allocation.uuid, fields),
|
||||
headers=self.headers)
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['resource_class', 'extra', 'links'], data)
|
||||
self.assertCountEqual(['resource_class', 'extra', 'links'], data)
|
||||
|
||||
def test_get_collection_custom_fields(self):
|
||||
fields = 'uuid,extra'
|
||||
@ -132,7 +132,7 @@ class TestListAllocations(test_api_base.BaseApiTest):
|
||||
self.assertEqual(3, len(data['allocations']))
|
||||
for allocation in data['allocations']:
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['uuid', 'extra', 'links'], allocation)
|
||||
self.assertCountEqual(['uuid', 'extra', 'links'], allocation)
|
||||
|
||||
def test_get_custom_fields_invalid_fields(self):
|
||||
allocation = obj_utils.create_test_allocation(self.context,
|
||||
|
@ -78,7 +78,7 @@ class TestListChassis(test_api_base.BaseApiTest):
|
||||
'/chassis/%s?fields=%s' % (chassis.uuid, fields),
|
||||
headers={api_base.Version.string: str(api_v1.max_version())})
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['description', 'extra', 'links'], data)
|
||||
self.assertCountEqual(['description', 'extra', 'links'], data)
|
||||
|
||||
def test_get_collection_custom_fields(self):
|
||||
fields = 'uuid,extra'
|
||||
@ -93,7 +93,7 @@ class TestListChassis(test_api_base.BaseApiTest):
|
||||
self.assertEqual(3, len(data['chassis']))
|
||||
for ch in data['chassis']:
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['uuid', 'extra', 'links'], ch)
|
||||
self.assertCountEqual(['uuid', 'extra', 'links'], ch)
|
||||
|
||||
def test_get_custom_fields_invalid_fields(self):
|
||||
chassis = obj_utils.create_test_chassis(self.context)
|
||||
|
@ -120,7 +120,7 @@ class TestListConductors(test_api_base.BaseApiTest):
|
||||
data = self.get_json(
|
||||
'/conductors/rocky.rocks?fields=%s' % fields,
|
||||
headers={api_base.Version.string: str(api_v1.max_version())})
|
||||
self.assertItemsEqual(['hostname', 'alive', 'links'], data)
|
||||
self.assertCountEqual(['hostname', 'alive', 'links'], data)
|
||||
|
||||
def test_get_collection_custom_fields(self):
|
||||
obj_utils.create_test_conductor(self.context, hostname='rocky.rocks')
|
||||
@ -133,7 +133,7 @@ class TestListConductors(test_api_base.BaseApiTest):
|
||||
|
||||
self.assertEqual(2, len(data['conductors']))
|
||||
for c in data['conductors']:
|
||||
self.assertItemsEqual(['hostname', 'alive', 'links'], c)
|
||||
self.assertCountEqual(['hostname', 'alive', 'links'], c)
|
||||
|
||||
def test_get_custom_fields_invalid_fields(self):
|
||||
obj_utils.create_test_conductor(self.context, hostname='rocky.rocks')
|
||||
|
@ -119,7 +119,7 @@ class TestListDeployTemplates(BaseDeployTemplatesAPITest):
|
||||
'/deploy_templates/%s?fields=%s' % (template.uuid, fields),
|
||||
headers=self.headers)
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['name', 'steps', 'links'], data)
|
||||
self.assertCountEqual(['name', 'steps', 'links'], data)
|
||||
|
||||
def test_get_collection_custom_fields(self):
|
||||
fields = 'uuid,steps'
|
||||
@ -136,7 +136,7 @@ class TestListDeployTemplates(BaseDeployTemplatesAPITest):
|
||||
self.assertEqual(3, len(data['deploy_templates']))
|
||||
for template in data['deploy_templates']:
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['uuid', 'steps', 'links'], template)
|
||||
self.assertCountEqual(['uuid', 'steps', 'links'], template)
|
||||
|
||||
def test_get_custom_fields_invalid_fields(self):
|
||||
template = obj_utils.create_test_deploy_template(self.context)
|
||||
|
@ -434,7 +434,7 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
'/nodes/%s?fields=%s' % (node.uuid, fields),
|
||||
headers={api_base.Version.string: str(api_v1.max_version())})
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['extra', 'instance_info', 'links'], data)
|
||||
self.assertCountEqual(['extra', 'instance_info', 'links'], data)
|
||||
|
||||
def test_get_collection_custom_fields(self):
|
||||
fields = 'uuid,instance_info'
|
||||
@ -450,7 +450,7 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
self.assertEqual(3, len(data['nodes']))
|
||||
for node in data['nodes']:
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['uuid', 'instance_info', 'links'], node)
|
||||
self.assertCountEqual(['uuid', 'instance_info', 'links'], node)
|
||||
|
||||
def test_get_custom_fields_invalid_fields(self):
|
||||
node = obj_utils.create_test_node(self.context,
|
||||
@ -483,7 +483,7 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
'/nodes/%s?fields=%s' % (node.uuid, fields),
|
||||
headers={api_base.Version.string: str(api_v1.max_version())})
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['driver_info', 'links'], data)
|
||||
self.assertCountEqual(['driver_info', 'links'], data)
|
||||
self.assertEqual('******', data['driver_info']['fake_password'])
|
||||
|
||||
def test_get_network_interface_fields_invalid_api_version(self):
|
||||
|
@ -328,7 +328,7 @@ class TestListPorts(test_api_base.BaseApiTest):
|
||||
'/ports/%s?fields=%s' % (port.uuid, fields),
|
||||
headers={api_base.Version.string: str(api_v1.max_version())})
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['address', 'extra', 'links'], data)
|
||||
self.assertCountEqual(['address', 'extra', 'links'], data)
|
||||
|
||||
def test_hide_fields_in_newer_versions_internal_info(self):
|
||||
port = obj_utils.create_test_port(self.context, node_id=self.node.id,
|
||||
@ -423,7 +423,7 @@ class TestListPorts(test_api_base.BaseApiTest):
|
||||
self.assertEqual(3, len(data['ports']))
|
||||
for port in data['ports']:
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['uuid', 'extra', 'links'], port)
|
||||
self.assertCountEqual(['uuid', 'extra', 'links'], port)
|
||||
|
||||
def test_get_collection_next_marker_no_uuid(self):
|
||||
fields = 'address'
|
||||
@ -479,7 +479,7 @@ class TestListPorts(test_api_base.BaseApiTest):
|
||||
'/ports/%s?fields=%s' % (port.uuid, fields),
|
||||
headers={api_base.Version.string: "1.34"})
|
||||
# We always append "links".
|
||||
self.assertItemsEqual(['uuid', 'physical_network', 'links'], response)
|
||||
self.assertCountEqual(['uuid', 'physical_network', 'links'], response)
|
||||
|
||||
@mock.patch.object(objects.Port, 'supports_physical_network')
|
||||
def test_get_custom_fields_physical_network_upgrade(self, mock_spn):
|
||||
@ -509,7 +509,7 @@ class TestListPorts(test_api_base.BaseApiTest):
|
||||
|
||||
# 'links' field is always retrieved in the response
|
||||
# regardless of which fields are specified.
|
||||
self.assertItemsEqual(['uuid', 'is_smartnic', 'links'], response)
|
||||
self.assertCountEqual(['uuid', 'is_smartnic', 'links'], response)
|
||||
|
||||
def test_detail(self):
|
||||
llc = {'switch_info': 'switch', 'switch_id': 'aa:bb:cc:dd:ee:ff',
|
||||
|
@ -127,7 +127,7 @@ class TestListPortgroups(test_api_base.BaseApiTest):
|
||||
'/portgroups/%s?fields=%s' % (portgroup.uuid, fields),
|
||||
headers=self.headers)
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['address', 'extra', 'links'], data)
|
||||
self.assertCountEqual(['address', 'extra', 'links'], data)
|
||||
|
||||
def test_get_one_mode_field_lower_api_version(self):
|
||||
portgroup = obj_utils.create_test_portgroup(self.context,
|
||||
@ -157,7 +157,7 @@ class TestListPortgroups(test_api_base.BaseApiTest):
|
||||
self.assertEqual(3, len(data['portgroups']))
|
||||
for portgroup in data['portgroups']:
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['uuid', 'extra', 'links'], portgroup)
|
||||
self.assertCountEqual(['uuid', 'extra', 'links'], portgroup)
|
||||
|
||||
def test_get_collection_properties_field_lower_api_version(self):
|
||||
obj_utils.create_test_portgroup(self.context, node_id=self.node.id)
|
||||
|
@ -145,7 +145,7 @@ class TestJsonPatchType(api_base.BaseApiTest):
|
||||
'value': {'cat': 'meow'}}]
|
||||
ret = self._patch_json(valid_patches, False)
|
||||
self.assertEqual(http_client.OK, ret.status_int)
|
||||
self.assertItemsEqual(valid_patches, ret.json)
|
||||
self.assertCountEqual(valid_patches, ret.json)
|
||||
|
||||
def test_cannot_update_internal_attr(self):
|
||||
patch = [{'path': '/internal', 'op': 'replace', 'value': 'foo'}]
|
||||
@ -301,14 +301,14 @@ class TestLocalLinkConnectionType(base.TestCase):
|
||||
value = {'switch_id': '0a:1b:2c:3d:4e:5f',
|
||||
'port_id': 'value2',
|
||||
'switch_info': 'value3'}
|
||||
self.assertItemsEqual(value, v.validate(value))
|
||||
self.assertCountEqual(value, v.validate(value))
|
||||
|
||||
def test_local_link_connection_type_datapath_id(self):
|
||||
v = types.locallinkconnectiontype
|
||||
value = {'switch_id': '0000000000000000',
|
||||
'port_id': 'value2',
|
||||
'switch_info': 'value3'}
|
||||
self.assertItemsEqual(value,
|
||||
self.assertCountEqual(value,
|
||||
v.validate(value))
|
||||
|
||||
def test_local_link_connection_type_not_mac_or_datapath_id(self):
|
||||
@ -338,12 +338,12 @@ class TestLocalLinkConnectionType(base.TestCase):
|
||||
v = types.locallinkconnectiontype
|
||||
value = {'switch_id': '0a:1b:2c:3d:4e:5f',
|
||||
'port_id': 'value2'}
|
||||
self.assertItemsEqual(value, v.validate(value))
|
||||
self.assertCountEqual(value, v.validate(value))
|
||||
|
||||
def test_local_link_connection_type_empty_value(self):
|
||||
v = types.locallinkconnectiontype
|
||||
value = {}
|
||||
self.assertItemsEqual(value, v.validate(value))
|
||||
self.assertCountEqual(value, v.validate(value))
|
||||
|
||||
def test_local_link_connection_type_smart_nic_keys_mandatory(self):
|
||||
v = types.locallinkconnectiontype
|
||||
@ -376,14 +376,14 @@ class TestLocalLinkConnectionType(base.TestCase):
|
||||
def test_local_link_connection_net_type_unmanaged(self):
|
||||
v = types.locallinkconnectiontype
|
||||
value = {'network_type': 'unmanaged'}
|
||||
self.assertItemsEqual(value, v.validate(value))
|
||||
self.assertCountEqual(value, v.validate(value))
|
||||
|
||||
def test_local_link_connection_net_type_unmanaged_combine_ok(self):
|
||||
v = types.locallinkconnectiontype
|
||||
value = {'network_type': 'unmanaged',
|
||||
'switch_id': '0a:1b:2c:3d:4e:5f',
|
||||
'port_id': 'rep0-0'}
|
||||
self.assertItemsEqual(value, v.validate(value))
|
||||
self.assertCountEqual(value, v.validate(value))
|
||||
|
||||
def test_local_link_connection_net_type_invalid(self):
|
||||
v = types.locallinkconnectiontype
|
||||
@ -397,7 +397,7 @@ class TestVifType(base.TestCase):
|
||||
def test_vif_type(self):
|
||||
v = types.viftype
|
||||
value = {'id': 'foo'}
|
||||
self.assertItemsEqual(value, v.validate(value))
|
||||
self.assertCountEqual(value, v.validate(value))
|
||||
|
||||
def test_vif_type_missing_mandatory_key(self):
|
||||
v = types.viftype
|
||||
@ -408,7 +408,7 @@ class TestVifType(base.TestCase):
|
||||
def test_vif_type_optional_key(self):
|
||||
v = types.viftype
|
||||
value = {'id': 'foo', 'misc': 'something'}
|
||||
self.assertItemsEqual(value, v.frombasetype(value))
|
||||
self.assertCountEqual(value, v.frombasetype(value))
|
||||
|
||||
def test_vif_type_bad_id(self):
|
||||
v = types.viftype
|
||||
@ -427,7 +427,7 @@ class TestEventType(base.TestCase):
|
||||
@mock.patch.object(types.EventType, 'valid_events', set(['valid.event']))
|
||||
def test_simple_event_type(self):
|
||||
value = {'event': 'valid.event'}
|
||||
self.assertItemsEqual(value, self.v.validate(value))
|
||||
self.assertCountEqual(value, self.v.validate(value))
|
||||
|
||||
@mock.patch.object(types.EventType, 'valid_events', set(['valid.event']))
|
||||
def test_invalid_event_type(self):
|
||||
@ -450,7 +450,7 @@ class TestEventType(base.TestCase):
|
||||
'binding:host_id': '22222222-aaaa-bbbb-cccc-555555555555',
|
||||
'binding:vnic_type': 'baremetal'
|
||||
}
|
||||
self.assertItemsEqual(value, self.v.validate(value))
|
||||
self.assertCountEqual(value, self.v.validate(value))
|
||||
|
||||
def test_invalid_mac_network_port_event(self):
|
||||
value = {'event': 'network.bind_port',
|
||||
|
@ -114,7 +114,7 @@ class TestListVolumeConnectors(test_api_base.BaseApiTest):
|
||||
'/volume/connectors/%s?fields=%s' % (connector.uuid, fields),
|
||||
headers=self.headers)
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['connector_id', 'extra', 'links'], data)
|
||||
self.assertCountEqual(['connector_id', 'extra', 'links'], data)
|
||||
|
||||
def test_get_collection_custom_fields(self):
|
||||
fields = 'uuid,extra'
|
||||
@ -131,7 +131,7 @@ class TestListVolumeConnectors(test_api_base.BaseApiTest):
|
||||
self.assertEqual(3, len(data['connectors']))
|
||||
for connector in data['connectors']:
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['uuid', 'extra', 'links'], connector)
|
||||
self.assertCountEqual(['uuid', 'extra', 'links'], connector)
|
||||
|
||||
def test_get_custom_fields_invalid_fields(self):
|
||||
connector = obj_utils.create_test_volume_connector(
|
||||
|
@ -114,7 +114,7 @@ class TestListVolumeTargets(test_api_base.BaseApiTest):
|
||||
'/volume/targets/%s?fields=%s' % (target.uuid, fields),
|
||||
headers=self.headers)
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['boot_index', 'extra', 'links'], data)
|
||||
self.assertCountEqual(['boot_index', 'extra', 'links'], data)
|
||||
|
||||
def test_get_collection_custom_fields(self):
|
||||
fields = 'uuid,extra'
|
||||
@ -130,7 +130,7 @@ class TestListVolumeTargets(test_api_base.BaseApiTest):
|
||||
self.assertEqual(3, len(data['targets']))
|
||||
for target in data['targets']:
|
||||
# We always append "links"
|
||||
self.assertItemsEqual(['uuid', 'extra', 'links'], target)
|
||||
self.assertCountEqual(['uuid', 'extra', 'links'], target)
|
||||
|
||||
def test_get_custom_fields_invalid_fields(self):
|
||||
target = obj_utils.create_test_volume_target(
|
||||
|
@ -1344,7 +1344,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase):
|
||||
'opt_value': '192.0.2.1',
|
||||
'ip_version': ip_version}]
|
||||
|
||||
self.assertItemsEqual(expected_info,
|
||||
self.assertCountEqual(expected_info,
|
||||
pxe_utils.dhcp_options_for_instance(
|
||||
task, ipxe_enabled=True))
|
||||
|
||||
@ -1375,7 +1375,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase):
|
||||
'opt_value': '192.0.2.1',
|
||||
'ip_version': ip_version}]
|
||||
|
||||
self.assertItemsEqual(expected_info,
|
||||
self.assertCountEqual(expected_info,
|
||||
pxe_utils.dhcp_options_for_instance(
|
||||
task, ipxe_enabled=True))
|
||||
|
||||
|
@ -62,9 +62,9 @@ class DbBIOSSettingTestCase(base.DbTestCase):
|
||||
settings = db_utils.get_test_bios_setting_setting_list()
|
||||
result = self.dbapi.create_bios_setting_list(
|
||||
self.node.id, settings, '1.0')
|
||||
self.assertItemsEqual(['virtualization', 'hyperthread', 'numlock'],
|
||||
self.assertCountEqual(['virtualization', 'hyperthread', 'numlock'],
|
||||
[setting.name for setting in result])
|
||||
self.assertItemsEqual(['on', 'enabled', 'off'],
|
||||
self.assertCountEqual(['on', 'enabled', 'off'],
|
||||
[setting.value for setting in result])
|
||||
|
||||
def test_create_bios_setting_list_duplicate(self):
|
||||
@ -87,7 +87,7 @@ class DbBIOSSettingTestCase(base.DbTestCase):
|
||||
{'name': 'numlock', 'value': 'on'}]
|
||||
result = self.dbapi.update_bios_setting_list(
|
||||
self.node.id, settings, '1.0')
|
||||
self.assertItemsEqual(['off', 'disabled', 'on'],
|
||||
self.assertCountEqual(['off', 'disabled', 'on'],
|
||||
[setting.value for setting in result])
|
||||
|
||||
def test_update_bios_setting_list_setting_not_exist(self):
|
||||
|
@ -26,7 +26,7 @@ class DbNodeTagTestCase(base.DbTestCase):
|
||||
def test_set_node_tags(self):
|
||||
tags = self.dbapi.set_node_tags(self.node.id, ['tag1', 'tag2'])
|
||||
self.assertEqual(self.node.id, tags[0].node_id)
|
||||
self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in tags])
|
||||
self.assertCountEqual(['tag1', 'tag2'], [tag.tag for tag in tags])
|
||||
|
||||
tags = self.dbapi.set_node_tags(self.node.id, [])
|
||||
self.assertEqual([], tags)
|
||||
@ -35,7 +35,7 @@ class DbNodeTagTestCase(base.DbTestCase):
|
||||
tags = self.dbapi.set_node_tags(self.node.id,
|
||||
['tag1', 'tag2', 'tag2'])
|
||||
self.assertEqual(self.node.id, tags[0].node_id)
|
||||
self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in tags])
|
||||
self.assertCountEqual(['tag1', 'tag2'], [tag.tag for tag in tags])
|
||||
|
||||
def test_set_node_tags_node_not_exist(self):
|
||||
self.assertRaises(exception.NodeNotFound,
|
||||
@ -45,7 +45,7 @@ class DbNodeTagTestCase(base.DbTestCase):
|
||||
self.dbapi.set_node_tags(self.node.id, ['tag1', 'tag2'])
|
||||
tags = self.dbapi.get_node_tags_by_node_id(self.node.id)
|
||||
self.assertEqual(self.node.id, tags[0].node_id)
|
||||
self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in tags])
|
||||
self.assertCountEqual(['tag1', 'tag2'], [tag.tag for tag in tags])
|
||||
|
||||
def test_get_node_tags_empty(self):
|
||||
tags = self.dbapi.get_node_tags_by_node_id(self.node.id)
|
||||
|
@ -27,7 +27,7 @@ class DbNodeTraitTestCase(base.DbTestCase):
|
||||
result = self.dbapi.set_node_traits(self.node.id, ['trait1', 'trait2'],
|
||||
'1.0')
|
||||
self.assertEqual(self.node.id, result[0].node_id)
|
||||
self.assertItemsEqual(['trait1', 'trait2'],
|
||||
self.assertCountEqual(['trait1', 'trait2'],
|
||||
[trait.trait for trait in result])
|
||||
|
||||
result = self.dbapi.set_node_traits(self.node.id, [], '1.0')
|
||||
@ -38,14 +38,14 @@ class DbNodeTraitTestCase(base.DbTestCase):
|
||||
['trait1', 'trait2', 'trait2'],
|
||||
'1.0')
|
||||
self.assertEqual(self.node.id, result[0].node_id)
|
||||
self.assertItemsEqual(['trait1', 'trait2'],
|
||||
self.assertCountEqual(['trait1', 'trait2'],
|
||||
[trait.trait for trait in result])
|
||||
|
||||
def test_set_node_traits_at_limit(self):
|
||||
traits = ['trait%d' % n for n in range(50)]
|
||||
result = self.dbapi.set_node_traits(self.node.id, traits, '1.0')
|
||||
self.assertEqual(self.node.id, result[0].node_id)
|
||||
self.assertItemsEqual(traits, [trait.trait for trait in result])
|
||||
self.assertCountEqual(traits, [trait.trait for trait in result])
|
||||
|
||||
def test_set_node_traits_over_limit(self):
|
||||
traits = ['trait%d' % n for n in range(51)]
|
||||
@ -66,7 +66,7 @@ class DbNodeTraitTestCase(base.DbTestCase):
|
||||
traits=['trait1', 'trait2'])
|
||||
result = self.dbapi.get_node_traits_by_node_id(self.node.id)
|
||||
self.assertEqual(self.node.id, result[0].node_id)
|
||||
self.assertItemsEqual(['trait1', 'trait2'],
|
||||
self.assertCountEqual(['trait1', 'trait2'],
|
||||
[trait.trait for trait in result])
|
||||
|
||||
def test_get_node_traits_empty(self):
|
||||
|
@ -72,8 +72,8 @@ class DbNodeTestCase(base.DbTestCase):
|
||||
res = self.dbapi.get_node_by_id(node.id)
|
||||
self.assertEqual(node.id, res.id)
|
||||
self.assertEqual(node.uuid, res.uuid)
|
||||
self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertItemsEqual(['trait1', 'trait2'],
|
||||
self.assertCountEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertCountEqual(['trait1', 'trait2'],
|
||||
[trait.trait for trait in res.traits])
|
||||
|
||||
def test_get_node_by_uuid(self):
|
||||
@ -84,8 +84,8 @@ class DbNodeTestCase(base.DbTestCase):
|
||||
res = self.dbapi.get_node_by_uuid(node.uuid)
|
||||
self.assertEqual(node.id, res.id)
|
||||
self.assertEqual(node.uuid, res.uuid)
|
||||
self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertItemsEqual(['trait1', 'trait2'],
|
||||
self.assertCountEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertCountEqual(['trait1', 'trait2'],
|
||||
[trait.trait for trait in res.traits])
|
||||
|
||||
def test_get_node_by_name(self):
|
||||
@ -97,8 +97,8 @@ class DbNodeTestCase(base.DbTestCase):
|
||||
self.assertEqual(node.id, res.id)
|
||||
self.assertEqual(node.uuid, res.uuid)
|
||||
self.assertEqual(node.name, res.name)
|
||||
self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertItemsEqual(['trait1', 'trait2'],
|
||||
self.assertCountEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertCountEqual(['trait1', 'trait2'],
|
||||
[trait.trait for trait in res.traits])
|
||||
|
||||
def test_get_node_that_does_not_exist(self):
|
||||
@ -455,8 +455,8 @@ class DbNodeTestCase(base.DbTestCase):
|
||||
|
||||
res = self.dbapi.get_node_by_instance(node.instance_uuid)
|
||||
self.assertEqual(node.uuid, res.uuid)
|
||||
self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertItemsEqual(['trait1', 'trait2'],
|
||||
self.assertCountEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertCountEqual(['trait1', 'trait2'],
|
||||
[trait.trait for trait in res.traits])
|
||||
|
||||
def test_get_node_by_instance_wrong_uuid(self):
|
||||
@ -723,8 +723,8 @@ class DbNodeTestCase(base.DbTestCase):
|
||||
|
||||
# reserve the node
|
||||
res = self.dbapi.reserve_node(r1, uuid)
|
||||
self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertItemsEqual(['trait1', 'trait2'],
|
||||
self.assertCountEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
|
||||
self.assertCountEqual(['trait1', 'trait2'],
|
||||
[trait.trait for trait in res.traits])
|
||||
|
||||
# check reservation
|
||||
|
@ -96,7 +96,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
{'anyphysnet'}))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[pg1.uuid, self.port.uuid] + [p.uuid for p in pg2_ports[:2]],
|
||||
[p.uuid for p in free_port_like_objs])
|
||||
|
||||
@ -109,7 +109,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
set()))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[pg1.uuid, self.port.uuid] + [p.uuid for p in pg2_ports[:2]],
|
||||
[p.uuid for p in free_port_like_objs])
|
||||
|
||||
@ -122,7 +122,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
{'notaphysnet'}))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[self.port.uuid],
|
||||
[p.uuid for p in free_port_like_objs])
|
||||
|
||||
@ -135,7 +135,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
{'physnet1'}))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[pg1.uuid, self.port.uuid],
|
||||
[p.uuid for p in free_port_like_objs])
|
||||
|
||||
@ -148,7 +148,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
{'physnet2'}))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[self.port.uuid] + [p.uuid for p in pg2_ports[:2]],
|
||||
[p.uuid for p in free_port_like_objs])
|
||||
|
||||
@ -161,7 +161,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
{'physnet3'}))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[self.port.uuid], [p.uuid for p in free_port_like_objs])
|
||||
|
||||
def test__get_free_portgroups_and_ports_all_physnets(self):
|
||||
@ -174,7 +174,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
physnets))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[pg1.uuid, self.port.uuid] + [p.uuid for p in pg2_ports[:2]],
|
||||
[p.uuid for p in free_port_like_objs])
|
||||
|
||||
@ -185,7 +185,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
{'anyphysnet'}))
|
||||
self.assertItemsEqual([], free_port_like_objs)
|
||||
self.assertCountEqual([], free_port_like_objs)
|
||||
|
||||
@mock.patch.object(neutron_common, 'validate_port_info', autospec=True)
|
||||
def test__get_free_portgroups_and_ports_neutron(self, vpi_mock):
|
||||
@ -194,7 +194,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
{'anyphysnet'}))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[self.port.uuid], [p.uuid for p in free_port_like_objs])
|
||||
|
||||
@mock.patch.object(neutron_common, 'validate_port_info', autospec=True)
|
||||
@ -206,7 +206,7 @@ class TestCommonFunctions(db_base.DbTestCase):
|
||||
free_port_like_objs = (
|
||||
common._get_free_portgroups_and_ports(task, self.vif_id,
|
||||
{'anyphysnet'}))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[self.port.uuid], [p.uuid for p in free_port_like_objs])
|
||||
|
||||
@mock.patch.object(neutron_common, 'validate_port_info', autospec=True,
|
||||
@ -606,7 +606,7 @@ class TestVifPortIDMixin(db_base.DbTestCase):
|
||||
address='52:54:00:cf:2d:01', uuid=uuidutils.generate_uuid())
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
vifs = self.interface.vif_list(task)
|
||||
self.assertItemsEqual([{'id': pg_vif_id}, {'id': vif_id}], vifs)
|
||||
self.assertCountEqual([{'id': pg_vif_id}, {'id': vif_id}], vifs)
|
||||
|
||||
def test_vif_list_internal(self):
|
||||
vif_id = uuidutils.generate_uuid()
|
||||
@ -622,7 +622,7 @@ class TestVifPortIDMixin(db_base.DbTestCase):
|
||||
address='52:54:00:cf:2d:01', uuid=uuidutils.generate_uuid())
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
vifs = self.interface.vif_list(task)
|
||||
self.assertItemsEqual([{'id': pg_vif_id}, {'id': vif_id}], vifs)
|
||||
self.assertCountEqual([{'id': pg_vif_id}, {'id': vif_id}], vifs)
|
||||
|
||||
def test_vif_list_extra_and_internal_priority(self):
|
||||
vif_id = uuidutils.generate_uuid()
|
||||
|
@ -88,7 +88,7 @@ class XClarityManagementDriverTestCase(db_base.DbTestCase):
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
expected = [boot_devices.PXE, boot_devices.BIOS,
|
||||
boot_devices.DISK, boot_devices.CDROM]
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
expected,
|
||||
task.driver.management.get_supported_boot_devices(task))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user