From f65ba0792c9c5d339d9026c00303ff15389f71ae Mon Sep 17 00:00:00 2001 From: Shivanand Tendulker Date: Wed, 17 May 2017 02:25:58 -0400 Subject: [PATCH] Minor clean up in iLO drivers unit tests Removed mocks for LOG.debug and updated 'spec_set' and 'autospec' flags to some of the mock objects. Change-Id: I87c535ea6dc3a7fb4afb0343f7d5272b423883b3 --- ironic/tests/unit/drivers/modules/ilo/test_boot.py | 5 +---- ironic/tests/unit/drivers/modules/ilo/test_common.py | 7 +++---- ironic/tests/unit/drivers/modules/ilo/test_management.py | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ironic/tests/unit/drivers/modules/ilo/test_boot.py b/ironic/tests/unit/drivers/modules/ilo/test_boot.py index 04592fa0ee..1a5fd5de6f 100644 --- a/ironic/tests/unit/drivers/modules/ilo/test_boot.py +++ b/ironic/tests/unit/drivers/modules/ilo/test_boot.py @@ -560,21 +560,18 @@ class IloBootPrivateMethodsTestCase(db_base.DbTestCase): func_set_secure_boot_mode.assert_called_once_with(task, False) self.assertTrue(returned_state) - @mock.patch.object(ilo_boot.LOG, 'debug', spec_set=True, autospec=True) @mock.patch.object(ilo_boot, 'exception', spec_set=True, autospec=True) @mock.patch.object(ilo_common, 'get_secure_boot_mode', spec_set=True, autospec=True) def test__disable_secure_boot_exception(self, func_get_secure_boot_mode, - exception_mock, - mock_log): + exception_mock): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: exception_mock.IloOperationNotSupported = Exception func_get_secure_boot_mode.side_effect = Exception returned_state = ilo_boot._disable_secure_boot(task) func_get_secure_boot_mode.assert_called_once_with(task) - self.assertTrue(mock_log.called) self.assertFalse(returned_state) @mock.patch.object(ilo_common, 'update_boot_mode', spec_set=True, diff --git a/ironic/tests/unit/drivers/modules/ilo/test_common.py b/ironic/tests/unit/drivers/modules/ilo/test_common.py index 1b412c78d0..80bf84d0d4 100644 --- a/ironic/tests/unit/drivers/modules/ilo/test_common.py +++ b/ironic/tests/unit/drivers/modules/ilo/test_common.py @@ -852,8 +852,7 @@ class IloCommonMethodsTestCase(db_base.DbTestCase): assert_called_once_with("/webserver/tmp_image_file")) @mock.patch.object(swift, 'SwiftAPI', spec_set=True, autospec=True) - @mock.patch.object(ilo_common, 'LOG') - def test_copy_image_to_swift(self, LOG_mock, swift_api_mock): + def test_copy_image_to_swift(self, swift_api_mock): # | GIVEN | self.config(swift_ilo_container='ilo_container', group='ilo') self.config(swift_object_expiry_timeout=1, group='ilo') @@ -906,7 +905,7 @@ class IloCommonMethodsTestCase(db_base.DbTestCase): swift_obj_mock.delete_object.assert_called_once_with( container, object_name) - @mock.patch.object(ilo_common, 'LOG') + @mock.patch.object(ilo_common, 'LOG', spec_set=True, autospec=True) @mock.patch.object(swift, 'SwiftAPI', spec_set=True, autospec=True) def test_remove_image_from_swift_suppresses_notfound_exc( self, swift_api_mock, LOG_mock): @@ -925,7 +924,7 @@ class IloCommonMethodsTestCase(db_base.DbTestCase): LOG_mock.warning.assert_called_once_with( mock.ANY, {'associated_with_msg': "", 'err': raised_exc}) - @mock.patch.object(ilo_common, 'LOG') + @mock.patch.object(ilo_common, 'LOG', spec_set=True, autospec=True) @mock.patch.object(swift, 'SwiftAPI', spec_set=True, autospec=True) def test_remove_image_from_swift_suppresses_operror_exc( self, swift_api_mock, LOG_mock): diff --git a/ironic/tests/unit/drivers/modules/ilo/test_management.py b/ironic/tests/unit/drivers/modules/ilo/test_management.py index f83655733d..26f24a59bf 100644 --- a/ironic/tests/unit/drivers/modules/ilo/test_management.py +++ b/ironic/tests/unit/drivers/modules/ilo/test_management.py @@ -306,11 +306,10 @@ class IloManagementTestCase(db_base.DbTestCase): clean_step_mock.assert_called_once_with( task.node, 'activate_license', 'XXXXX-YYYYY-ZZZZZ-XYZZZ-XXYYZ') - @mock.patch.object(ilo_management, 'LOG', spec_set=True, autospec=True) @mock.patch.object(ilo_management, '_execute_ilo_clean_step', spec_set=True, autospec=True) def test_activate_license_no_or_invalid_format_license_key( - self, clean_step_mock, log_mock): + self, clean_step_mock): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: for license_key_value in (None, [], {}):