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
This commit is contained in:
Shivanand Tendulker 2017-05-17 02:25:58 -04:00
parent 20dba3fb88
commit f65ba0792c
3 changed files with 5 additions and 10 deletions

View File

@ -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,

View File

@ -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):

View File

@ -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, [], {}):