Merge "cleanup: Remove usage of some_dict.keys()"
This commit is contained in:
commit
93e35da7e3
@ -708,7 +708,7 @@ def get_controller_reserved_names(cls):
|
||||
if isinstance(member, rest.RestController)]
|
||||
|
||||
if hasattr(cls, '_custom_actions'):
|
||||
reserved_names += cls._custom_actions.keys()
|
||||
reserved_names += list(cls._custom_actions)
|
||||
|
||||
return reserved_names
|
||||
|
||||
|
@ -254,7 +254,7 @@ def check_and_update_node_interfaces(node, driver_or_hw_type=None):
|
||||
hardware_type.AbstractHardwareType)
|
||||
|
||||
if is_hardware_type:
|
||||
factories = _INTERFACE_LOADERS.keys()
|
||||
factories = list(_INTERFACE_LOADERS)
|
||||
else:
|
||||
# Only network and storage interfaces are dynamic for classic drivers
|
||||
factories = ['network', 'storage']
|
||||
|
@ -59,7 +59,7 @@ def _extract_attributes(image):
|
||||
output[attr] = getattr(image, attr, None)
|
||||
output['schema'] = image['schema']
|
||||
|
||||
for image_property in set(image.keys()) - set(IMAGE_ATTRIBUTES):
|
||||
for image_property in set(image) - set(IMAGE_ATTRIBUTES):
|
||||
output['properties'][image_property] = image[image_property]
|
||||
|
||||
return output
|
||||
|
@ -150,7 +150,7 @@ class DracManagement(base.ManagementInterface):
|
||||
in :mod:`ironic.common.boot_devices`.
|
||||
|
||||
"""
|
||||
return list(_BOOT_DEVICES_MAP.keys())
|
||||
return list(_BOOT_DEVICES_MAP)
|
||||
|
||||
@METRICS.timer('DracManagement.get_boot_device')
|
||||
def get_boot_device(self, task):
|
||||
|
@ -126,7 +126,7 @@ class IloManagement(base.ManagementInterface):
|
||||
in :mod:`ironic.common.boot_devices`.
|
||||
|
||||
"""
|
||||
return list(BOOT_DEVICE_MAPPING_TO_ILO.keys())
|
||||
return list(BOOT_DEVICE_MAPPING_TO_ILO)
|
||||
|
||||
@METRICS.timer('IloManagement.get_boot_device')
|
||||
def get_boot_device(self, task):
|
||||
|
@ -718,14 +718,14 @@ class TestListNodes(test_api_base.BaseApiTest):
|
||||
data = self.get_json(
|
||||
'/nodes/%s' % node.uuid,
|
||||
headers={'X-OpenStack-Ironic-API-Version': '1.24'})
|
||||
self.assertIn('portgroups', data.keys())
|
||||
self.assertIn('portgroups', data)
|
||||
|
||||
def test_portgroups_subresource_link_hidden_for_older_versions(self):
|
||||
node = obj_utils.create_test_node(self.context)
|
||||
data = self.get_json(
|
||||
'/nodes/%s' % node.uuid,
|
||||
headers={'X-OpenStack-Ironic-API-Version': '1.20'})
|
||||
self.assertNotIn('portgroups', data.keys())
|
||||
self.assertNotIn('portgroups', data)
|
||||
|
||||
def test_portgroups_subresource_old_api_version(self):
|
||||
node = obj_utils.create_test_node(self.context)
|
||||
|
@ -468,7 +468,7 @@ class TestListPorts(test_api_base.BaseApiTest):
|
||||
uuid=uuid,
|
||||
node_id=self.node.id)
|
||||
data = self.get_json('/ports/%s' % uuid)
|
||||
self.assertIn('links', data.keys())
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
@ -1054,10 +1054,10 @@ class TestPatch(test_api_base.BaseApiTest):
|
||||
self.port.save()
|
||||
|
||||
# mutate extra so we replace all of them
|
||||
extra = dict((k, extra[k] + 'x') for k in extra.keys())
|
||||
extra = dict((k, extra[k] + 'x') for k in extra)
|
||||
|
||||
patch = []
|
||||
for k in extra.keys():
|
||||
for k in extra:
|
||||
patch.append({'path': '/extra/%s' % k,
|
||||
'value': extra[k],
|
||||
'op': 'replace'})
|
||||
@ -1147,7 +1147,7 @@ class TestPatch(test_api_base.BaseApiTest):
|
||||
def test_add_multi(self, mock_upd):
|
||||
extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
|
||||
patch = []
|
||||
for k in extra.keys():
|
||||
for k in extra:
|
||||
patch.append({'path': '/extra/%s' % k,
|
||||
'value': extra[k],
|
||||
'op': 'add'})
|
||||
|
@ -281,18 +281,18 @@ class TestListPortgroups(test_api_base.BaseApiTest):
|
||||
data = self.get_json('/portgroups/%s/ports' % pg.uuid,
|
||||
headers=self.headers)
|
||||
self.assertEqual(2, len(data['ports']))
|
||||
self.assertNotIn('next', data.keys())
|
||||
self.assertNotIn('next', data)
|
||||
|
||||
data = self.get_json('/portgroups/%s/ports/detail' % pg.uuid,
|
||||
headers=self.headers)
|
||||
self.assertEqual(2, len(data['ports']))
|
||||
self.assertNotIn('next', data.keys())
|
||||
self.assertNotIn('next', data)
|
||||
|
||||
# Test collection pagination
|
||||
data = self.get_json('/portgroups/%s/ports?limit=1' % pg.uuid,
|
||||
headers=self.headers)
|
||||
self.assertEqual(1, len(data['ports']))
|
||||
self.assertIn('next', data.keys())
|
||||
self.assertIn('next', data)
|
||||
|
||||
# Test get one old api version, /portgroups controller not allowed
|
||||
response = self.get_json('/portgroups/%s/ports/%s' % (
|
||||
@ -724,10 +724,10 @@ class TestPatch(test_api_base.BaseApiTest):
|
||||
self.portgroup.save()
|
||||
|
||||
# mutate extra so we replace all of them
|
||||
extra = dict((k, extra[k] + 'x') for k in extra.keys())
|
||||
extra = dict((k, extra[k] + 'x') for k in extra)
|
||||
|
||||
patch = []
|
||||
for k in extra.keys():
|
||||
for k in extra:
|
||||
patch.append({'path': '/extra/%s' % k,
|
||||
'value': extra[k],
|
||||
'op': 'replace'})
|
||||
@ -830,7 +830,7 @@ class TestPatch(test_api_base.BaseApiTest):
|
||||
def test_add_multi(self, mock_upd):
|
||||
extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
|
||||
patch = []
|
||||
for k in extra.keys():
|
||||
for k in extra:
|
||||
patch.append({'path': '/extra/%s' % k,
|
||||
'value': extra[k],
|
||||
'op': 'add'})
|
||||
|
@ -231,7 +231,7 @@ class TestListVolumeConnectors(test_api_base.BaseApiTest):
|
||||
node_id=self.node.id)
|
||||
data = self.get_json('/volume/connectors/%s' % uuid,
|
||||
headers=self.headers)
|
||||
self.assertIn('links', data.keys())
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
@ -575,10 +575,10 @@ class TestPatch(test_api_base.BaseApiTest):
|
||||
self.connector.save()
|
||||
|
||||
# mutate extra so we replace all of them
|
||||
extra = dict((k, extra[k] + 'x') for k in extra.keys())
|
||||
extra = dict((k, extra[k] + 'x') for k in extra)
|
||||
|
||||
patch = []
|
||||
for k in extra.keys():
|
||||
for k in extra:
|
||||
patch.append({'path': '/extra/%s' % k,
|
||||
'value': extra[k],
|
||||
'op': 'replace'})
|
||||
@ -686,7 +686,7 @@ class TestPatch(test_api_base.BaseApiTest):
|
||||
def test_add_multi(self, mock_upd):
|
||||
extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
|
||||
patch = []
|
||||
for k in extra.keys():
|
||||
for k in extra:
|
||||
patch.append({'path': '/extra/%s' % k,
|
||||
'value': extra[k],
|
||||
'op': 'add'})
|
||||
|
@ -221,7 +221,7 @@ class TestListVolumeTargets(test_api_base.BaseApiTest):
|
||||
node_id=self.node.id)
|
||||
data = self.get_json('/volume/targets/%s' % uuid,
|
||||
headers=self.headers)
|
||||
self.assertIn('links', data.keys())
|
||||
self.assertIn('links', data)
|
||||
self.assertEqual(2, len(data['links']))
|
||||
self.assertIn(uuid, data['links'][0]['href'])
|
||||
for l in data['links']:
|
||||
@ -557,10 +557,10 @@ class TestPatch(test_api_base.BaseApiTest):
|
||||
self.target.save()
|
||||
|
||||
# mutate extra so we replace all of them
|
||||
extra = dict((k, extra[k] + 'x') for k in extra.keys())
|
||||
extra = dict((k, extra[k] + 'x') for k in extra)
|
||||
|
||||
patch = []
|
||||
for k in extra.keys():
|
||||
for k in extra:
|
||||
patch.append({'path': '/extra/%s' % k,
|
||||
'value': extra[k],
|
||||
'op': 'replace'})
|
||||
@ -672,7 +672,7 @@ class TestPatch(test_api_base.BaseApiTest):
|
||||
def test_add_multi(self, mock_upd):
|
||||
extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
|
||||
patch = []
|
||||
for k in extra.keys():
|
||||
for k in extra:
|
||||
patch.append({'path': '/extra/%s' % k,
|
||||
'value': extra[k],
|
||||
'op': 'add'})
|
||||
|
@ -50,7 +50,7 @@ class TestV1Root(base.BaseApiTest):
|
||||
self.assertNotIn(f, ['', []])
|
||||
# Check if all known resources are present and there are no extra ones.
|
||||
not_resources = ('id', 'links', 'media_types')
|
||||
actual_resources = tuple(set(data.keys()) - set(not_resources))
|
||||
actual_resources = tuple(set(data) - set(not_resources))
|
||||
expected_resources = (['chassis', 'drivers', 'nodes', 'ports'] +
|
||||
additional_expected_resources)
|
||||
self.assertEqual(sorted(expected_resources), sorted(actual_resources))
|
||||
|
@ -5538,7 +5538,7 @@ class ManagerTestProperties(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
|
||||
self.driver = driver_factory.get_driver(driver)
|
||||
self._start_service()
|
||||
properties = self.service.get_driver_properties(self.context, driver)
|
||||
self.assertEqual(sorted(expected), sorted(properties.keys()))
|
||||
self.assertEqual(sorted(expected), sorted(properties))
|
||||
|
||||
def test_driver_properties_fake(self):
|
||||
expected = ['A1', 'A2', 'B1', 'B2']
|
||||
@ -5633,7 +5633,7 @@ class ManagerTestHardwareTypeProperties(mgr_utils.ServiceSetUpMixin,
|
||||
self._start_service()
|
||||
properties = self.service.get_driver_properties(self.context,
|
||||
hardware_type)
|
||||
self.assertEqual(sorted(expected), sorted(properties.keys()))
|
||||
self.assertEqual(sorted(expected), sorted(properties))
|
||||
|
||||
def test_hardware_type_properties_manual_management(self):
|
||||
expected = ['deploy_kernel', 'deploy_ramdisk',
|
||||
|
@ -396,7 +396,7 @@ class PhysicalWorkTestCase(tests_base.TestCase):
|
||||
raise ValueError("Only the following kwargs are allowed in "
|
||||
"_test_deploy_partition_image: %(allowed)s. "
|
||||
"Disallowed values: %(disallowed)s."
|
||||
% {"allowed": ", ".join(deploy_args.keys()),
|
||||
% {"allowed": ", ".join(deploy_args),
|
||||
"disallowed": ", ".join(disallowed_values)})
|
||||
deploy_args.update(kwargs)
|
||||
|
||||
|
@ -1364,9 +1364,9 @@ class IPMIToolDriverTestCase(db_base.DbTestCase):
|
||||
|
||||
expected = list(ipmi.COMMON_PROPERTIES) + list(ipmi.CONSOLE_PROPERTIES)
|
||||
self.assertEqual(sorted(expected),
|
||||
sorted(self.driver.console.get_properties().keys()))
|
||||
sorted(self.driver.console.get_properties()))
|
||||
self.assertEqual(sorted(expected),
|
||||
sorted(self.driver.get_properties().keys()))
|
||||
sorted(self.driver.get_properties()))
|
||||
|
||||
@mock.patch.object(ipmi, '_exec_ipmitool', autospec=True)
|
||||
def test_get_power_state(self, mock_exec):
|
||||
|
@ -53,7 +53,7 @@ class FakeDriverTestCase(db_base.DbTestCase):
|
||||
def test_get_properties(self):
|
||||
expected = ['A1', 'A2', 'B1', 'B2']
|
||||
properties = self.driver.get_properties()
|
||||
self.assertEqual(sorted(expected), sorted(properties.keys()))
|
||||
self.assertEqual(sorted(expected), sorted(properties))
|
||||
|
||||
def test_power_interface(self):
|
||||
self.assertEqual({}, self.driver.power.get_properties())
|
||||
|
@ -70,7 +70,7 @@ class ManualManagementHardwareTestCase(db_base.DbTestCase):
|
||||
'force_persistent_boot_device']
|
||||
hardware_type = driver_factory.get_hardware_type("manual-management")
|
||||
properties = hardware_type.get_properties()
|
||||
self.assertEqual(sorted(expected_prop_keys), sorted(properties.keys()))
|
||||
self.assertEqual(sorted(expected_prop_keys), sorted(properties))
|
||||
|
||||
@mock.patch.object(driver_factory, 'default_interface', autospec=True)
|
||||
def test_get_properties_none(self, mock_def_iface):
|
||||
|
@ -349,11 +349,11 @@ class _TestObject(object):
|
||||
myobj3_fields = ['new_field']
|
||||
self.assertTrue(issubclass(TestSubclassedObject, MyObj))
|
||||
self.assertEqual(len(myobj_fields), len(MyObj.fields))
|
||||
self.assertEqual(set(myobj_fields), set(MyObj.fields.keys()))
|
||||
self.assertEqual(set(myobj_fields), set(MyObj.fields))
|
||||
self.assertEqual(len(myobj_fields) + len(myobj3_fields),
|
||||
len(TestSubclassedObject.fields))
|
||||
self.assertEqual(set(myobj_fields) | set(myobj3_fields),
|
||||
set(TestSubclassedObject.fields.keys()))
|
||||
set(TestSubclassedObject.fields))
|
||||
|
||||
def _test_get_changes(self, target_version='1.5'):
|
||||
obj = MyObj(self.context)
|
||||
|
Loading…
Reference in New Issue
Block a user