diff --git a/ironic/tests/unit/drivers/modules/amt/test_common.py b/ironic/tests/unit/drivers/modules/amt/test_common.py index 5b2ec08227..d82a9690a1 100644 --- a/ironic/tests/unit/drivers/modules/amt/test_common.py +++ b/ironic/tests/unit/drivers/modules/amt/test_common.py @@ -47,11 +47,11 @@ class AMTCommonMethodsTestCase(db_base.DbTestCase): def test_parse_driver_info(self): info = amt_common.parse_driver_info(self.node) - self.assertIsNotNone(info.get('address')) - self.assertIsNotNone(info.get('username')) - self.assertIsNotNone(info.get('password')) - self.assertIsNotNone(info.get('protocol')) - self.assertIsNotNone(info.get('uuid')) + self.assertIsNotNone(info['address']) + self.assertIsNotNone(info['username']) + self.assertIsNotNone(info['password']) + self.assertIsNotNone(info['protocol']) + self.assertIsNotNone(info['uuid']) def test_parse_driver_info_missing_address(self): del self.node.driver_info['amt_address'] @@ -73,7 +73,7 @@ class AMTCommonMethodsTestCase(db_base.DbTestCase): def test_parse_driver_info_missing_protocol(self): del self.node.driver_info['amt_protocol'] info = amt_common.parse_driver_info(self.node) - self.assertEqual('http', info.get('protocol')) + self.assertEqual('http', info['protocol']) def test_parse_driver_info_wrong_protocol(self): self.node.driver_info['amt_protocol'] = 'fake-protocol' diff --git a/ironic/tests/unit/drivers/modules/cimc/test_common.py b/ironic/tests/unit/drivers/modules/cimc/test_common.py index 03aa45d7e6..6dff4153ba 100644 --- a/ironic/tests/unit/drivers/modules/cimc/test_common.py +++ b/ironic/tests/unit/drivers/modules/cimc/test_common.py @@ -50,9 +50,9 @@ class ParseDriverInfoTestCase(CIMCBaseTestCase): def test_parse_driver_info(self): info = cimc_common.parse_driver_info(self.node) - self.assertIsNotNone(info.get('cimc_address')) - self.assertIsNotNone(info.get('cimc_username')) - self.assertIsNotNone(info.get('cimc_password')) + self.assertIsNotNone(info['cimc_address']) + self.assertIsNotNone(info['cimc_username']) + self.assertIsNotNone(info['cimc_password']) def test_parse_driver_info_missing_address(self): del self.node.driver_info['cimc_address'] @@ -110,9 +110,9 @@ class CIMCHandleTestCase(CIMCBaseTestCase): @mock.patch.object(cimc_common, 'handle_login', autospec=True) def test_cimc_handle(self, mock_login, mock_handle): mo_hand = mock.MagicMock() - mo_hand.username = self.node.driver_info.get('cimc_username') - mo_hand.password = self.node.driver_info.get('cimc_password') - mo_hand.name = self.node.driver_info.get('cimc_address') + mo_hand.username = self.node.driver_info['cimc_username'] + mo_hand.password = self.node.driver_info['cimc_password'] + mo_hand.name = self.node.driver_info['cimc_address'] mock_handle.return_value = mo_hand info = cimc_common.parse_driver_info(self.node) diff --git a/ironic/tests/unit/drivers/modules/drac/test_common.py b/ironic/tests/unit/drivers/modules/drac/test_common.py index 31edb0f2a7..4bd480a566 100644 --- a/ironic/tests/unit/drivers/modules/drac/test_common.py +++ b/ironic/tests/unit/drivers/modules/drac/test_common.py @@ -35,12 +35,12 @@ class DracCommonMethodsTestCase(db_base.DbTestCase): driver_info=INFO_DICT) info = drac_common.parse_driver_info(node) - self.assertIsNotNone(info.get('drac_host')) - self.assertIsNotNone(info.get('drac_port')) - self.assertIsNotNone(info.get('drac_path')) - self.assertIsNotNone(info.get('drac_protocol')) - self.assertIsNotNone(info.get('drac_username')) - self.assertIsNotNone(info.get('drac_password')) + self.assertIsNotNone(info['drac_host']) + self.assertIsNotNone(info['drac_port']) + self.assertIsNotNone(info['drac_path']) + self.assertIsNotNone(info['drac_protocol']) + self.assertIsNotNone(info['drac_username']) + self.assertIsNotNone(info['drac_password']) def test_parse_driver_info_missing_host(self): node = obj_utils.create_test_node(self.context, @@ -57,7 +57,7 @@ class DracCommonMethodsTestCase(db_base.DbTestCase): del node.driver_info['drac_port'] info = drac_common.parse_driver_info(node) - self.assertEqual(443, info.get('drac_port')) + self.assertEqual(443, info['drac_port']) def test_parse_driver_info_invalid_port(self): node = obj_utils.create_test_node(self.context, @@ -74,7 +74,7 @@ class DracCommonMethodsTestCase(db_base.DbTestCase): del node.driver_info['drac_path'] info = drac_common.parse_driver_info(node) - self.assertEqual('/wsman', info.get('drac_path')) + self.assertEqual('/wsman', info['drac_path']) def test_parse_driver_info_missing_protocol(self): node = obj_utils.create_test_node(self.context, @@ -83,7 +83,7 @@ class DracCommonMethodsTestCase(db_base.DbTestCase): del node.driver_info['drac_protocol'] info = drac_common.parse_driver_info(node) - self.assertEqual('https', info.get('drac_protocol')) + self.assertEqual('https', info['drac_protocol']) def test_parse_driver_info_invalid_protocol(self): node = obj_utils.create_test_node(self.context, diff --git a/ironic/tests/unit/drivers/modules/ilo/test_boot.py b/ironic/tests/unit/drivers/modules/ilo/test_boot.py index 93ea84c4b2..48c8c9dc1b 100644 --- a/ironic/tests/unit/drivers/modules/ilo/test_boot.py +++ b/ironic/tests/unit/drivers/modules/ilo/test_boot.py @@ -600,11 +600,9 @@ class IloVirtualMediaBootTestCase(db_base.DbTestCase): cleanup_iso_mock.assert_called_once_with(task.node) cleanup_vmedia_mock.assert_called_once_with(task) driver_internal_info = task.node.driver_internal_info - boot_iso_created = driver_internal_info.get( - 'boot_iso_created_in_web_server') - root_uuid = driver_internal_info.get('root_uuid_or_disk_id') - self.assertIsNone(boot_iso_created) - self.assertIsNone(root_uuid) + self.assertNotIn('boot_iso_created_in_web_server', + driver_internal_info) + self.assertNotIn('root_uuid_or_disk_id', driver_internal_info) @mock.patch.object(ilo_common, 'cleanup_vmedia_boot', spec_set=True, autospec=True) diff --git a/ironic/tests/unit/drivers/modules/ilo/test_common.py b/ironic/tests/unit/drivers/modules/ilo/test_common.py index ec692601cc..e42e99f1f5 100644 --- a/ironic/tests/unit/drivers/modules/ilo/test_common.py +++ b/ironic/tests/unit/drivers/modules/ilo/test_common.py @@ -62,11 +62,11 @@ class IloValidateParametersTestCase(db_base.DbTestCase): def test_parse_driver_info(self): info = ilo_common.parse_driver_info(self.node) - self.assertIsNotNone(info.get('ilo_address')) - self.assertIsNotNone(info.get('ilo_username')) - self.assertIsNotNone(info.get('ilo_password')) - self.assertIsNotNone(info.get('client_timeout')) - self.assertIsNotNone(info.get('client_port')) + self.assertIsNotNone(info['ilo_address']) + self.assertIsNotNone(info['ilo_username']) + self.assertIsNotNone(info['ilo_password']) + self.assertIsNotNone(info['client_timeout']) + self.assertIsNotNone(info['client_port']) def test_parse_driver_info_missing_address(self): del self.node.driver_info['ilo_address'] diff --git a/ironic/tests/unit/drivers/modules/ilo/test_deploy.py b/ironic/tests/unit/drivers/modules/ilo/test_deploy.py index c822b76baa..d8d53edc73 100644 --- a/ironic/tests/unit/drivers/modules/ilo/test_deploy.py +++ b/ironic/tests/unit/drivers/modules/ilo/test_deploy.py @@ -163,8 +163,7 @@ class IloDeployPrivateMethodsTestCase(db_base.DbTestCase): func_update_boot_mode.assert_called_once_with(task) bootmode = driver_utils.get_node_capability(task.node, "boot_mode") self.assertIsNone(bootmode) - deploy_boot_mode = task.node.instance_info.get('deploy_boot_mode') - self.assertIsNone(deploy_boot_mode) + self.assertNotIn('deploy_boot_mode', task.node.instance_info) @mock.patch.object(ilo_common, 'update_boot_mode', spec_set=True, autospec=True) @@ -187,8 +186,7 @@ class IloDeployPrivateMethodsTestCase(db_base.DbTestCase): self.assertFalse(func_update_boot_mode.called) bootmode = driver_utils.get_node_capability(task.node, "boot_mode") self.assertIsNone(bootmode) - deploy_boot_mode = task.node.instance_info.get('deploy_boot_mode') - self.assertIsNone(deploy_boot_mode) + self.assertNotIn('deploy_boot_mode', task.node.instance_info) class IloVirtualMediaIscsiDeployTestCase(db_base.DbTestCase): diff --git a/ironic/tests/unit/drivers/modules/ilo/test_management.py b/ironic/tests/unit/drivers/modules/ilo/test_management.py index b0c824c5c4..f83655733d 100644 --- a/ironic/tests/unit/drivers/modules/ilo/test_management.py +++ b/ironic/tests/unit/drivers/modules/ilo/test_management.py @@ -252,10 +252,9 @@ class IloManagementTestCase(db_base.DbTestCase): task.driver.management.reset_ilo_credential(task) clean_step_mock.assert_called_once_with( task.node, 'reset_ilo_credential', 'fake-password') - self.assertIsNone( - task.node.driver_info.get('ilo_change_password')) - self.assertEqual(task.node.driver_info['ilo_password'], - 'fake-password') + self.assertNotIn('ilo_change_password', task.node.driver_info) + self.assertEqual('fake-password', + task.node.driver_info['ilo_password']) @mock.patch.object(ilo_management, 'LOG', spec_set=True, autospec=True) @mock.patch.object(ilo_management, '_execute_ilo_clean_step', diff --git a/ironic/tests/unit/drivers/modules/irmc/test_common.py b/ironic/tests/unit/drivers/modules/irmc/test_common.py index 922d0c033d..dcb46646f5 100644 --- a/ironic/tests/unit/drivers/modules/irmc/test_common.py +++ b/ironic/tests/unit/drivers/modules/irmc/test_common.py @@ -43,17 +43,17 @@ class IRMCValidateParametersTestCase(db_base.DbTestCase): def test_parse_driver_info(self): info = irmc_common.parse_driver_info(self.node) - self.assertIsNotNone(info.get('irmc_address')) - self.assertIsNotNone(info.get('irmc_username')) - self.assertIsNotNone(info.get('irmc_password')) - self.assertIsNotNone(info.get('irmc_client_timeout')) - self.assertIsNotNone(info.get('irmc_port')) - self.assertIsNotNone(info.get('irmc_auth_method')) - self.assertIsNotNone(info.get('irmc_sensor_method')) - self.assertIsNotNone(info.get('irmc_snmp_version')) - self.assertIsNotNone(info.get('irmc_snmp_port')) - self.assertIsNotNone(info.get('irmc_snmp_community')) - self.assertFalse(info.get('irmc_snmp_security')) + self.assertIsNotNone(info['irmc_address']) + self.assertIsNotNone(info['irmc_username']) + self.assertIsNotNone(info['irmc_password']) + self.assertIsNotNone(info['irmc_client_timeout']) + self.assertIsNotNone(info['irmc_port']) + self.assertIsNotNone(info['irmc_auth_method']) + self.assertIsNotNone(info['irmc_sensor_method']) + self.assertIsNotNone(info['irmc_snmp_version']) + self.assertIsNotNone(info['irmc_snmp_port']) + self.assertIsNotNone(info['irmc_snmp_community']) + self.assertFalse(info['irmc_snmp_security']) def test_parse_driver_option_default(self): self.node.driver_info = { @@ -63,10 +63,10 @@ class IRMCValidateParametersTestCase(db_base.DbTestCase): } info = irmc_common.parse_driver_info(self.node) - self.assertEqual('basic', info.get('irmc_auth_method')) - self.assertEqual(443, info.get('irmc_port')) - self.assertEqual(60, info.get('irmc_client_timeout')) - self.assertEqual('ipmitool', info.get('irmc_sensor_method')) + self.assertEqual('basic', info['irmc_auth_method']) + self.assertEqual(443, info['irmc_port']) + self.assertEqual(60, info['irmc_client_timeout']) + self.assertEqual('ipmitool', info['irmc_sensor_method']) def test_parse_driver_info_missing_address(self): del self.node.driver_info['irmc_address'] diff --git a/ironic/tests/unit/drivers/modules/oneview/test_management.py b/ironic/tests/unit/drivers/modules/oneview/test_management.py index f1e1d1379e..214893c97a 100644 --- a/ironic/tests/unit/drivers/modules/oneview/test_management.py +++ b/ironic/tests/unit/drivers/modules/oneview/test_management.py @@ -89,7 +89,7 @@ class OneViewManagementDriverTestCase(db_base.DbTestCase): self.driver.management.set_boot_device(task, boot_devices.PXE) oneview_client.set_boot_device.assert_called_once_with( self.info, - management.BOOT_DEVICE_MAPPING_TO_OV.get(boot_devices.PXE) + management.BOOT_DEVICE_MAPPING_TO_OV[boot_devices.PXE] ) def test_set_boot_device_invalid_device(self, mock_get_ov_client): diff --git a/ironic/tests/unit/drivers/modules/ucs/test_helper.py b/ironic/tests/unit/drivers/modules/ucs/test_helper.py index 87b91e2801..cd78fa72c8 100644 --- a/ironic/tests/unit/drivers/modules/ucs/test_helper.py +++ b/ironic/tests/unit/drivers/modules/ucs/test_helper.py @@ -46,10 +46,10 @@ class UcsValidateParametersTestCase(db_base.DbTestCase): def test_parse_driver_info(self): info = ucs_helper.parse_driver_info(self.node) - self.assertIsNotNone(info.get('ucs_address')) - self.assertIsNotNone(info.get('ucs_username')) - self.assertIsNotNone(info.get('ucs_password')) - self.assertIsNotNone(info.get('ucs_service_profile')) + self.assertIsNotNone(info['ucs_address']) + self.assertIsNotNone(info['ucs_username']) + self.assertIsNotNone(info['ucs_password']) + self.assertIsNotNone(info['ucs_service_profile']) def test_parse_driver_info_missing_address(self):