Update tests for Redfish BIOS apply_configuration

Add new test case when supported_apply_times is None.
Clean up existing apply_configuration tests to not set up
bios.apply_time_settings as it is no longer used in implementation
and repurpose it for current implementation.

Co-Authored-By: Eric Barrera <eric_barrera@dell.com>
Co-Authored-By: Richard G. Pioso <richard.pioso@dell.com>
Co-Authored-By: Mike Raineri <mraineri@gmail.com>

Followup to I28a948f306b40c36b12e6f786e1e43a61e84a0f2

Change-Id: I923559c0dc60b1e618584b9dd7a1bf4ac6decb7f
This commit is contained in:
Aija Jauntēva 2020-09-23 09:19:19 -04:00
parent 65d5066394
commit 1a9020deb1
1 changed files with 25 additions and 7 deletions

View File

@ -190,7 +190,6 @@ class RedfishBiosTestCase(db_base.DbTestCase):
if step == 'factory_reset':
ret = task.driver.bios.factory_reset(task)
if step == 'apply_configuration':
bios.apply_time_settings = None
bios.supported_apply_times = []
ret = task.driver.bios.apply_configuration(task, data)
mock_get_system.assert_called_with(task.node)
@ -387,16 +386,15 @@ class RedfishBiosTestCase(db_base.DbTestCase):
@mock.patch.object(deploy_utils, 'build_agent_options', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
@mock.patch.object(manager_utils, 'node_power_action', autospec=True)
def test_apply_configuration_apply_time_settings(self, mock_power_action,
mock_get_system,
mock_build_agent_options,
mock_prepare):
def test_apply_configuration_apply_time_immediate(self, mock_power_action,
mock_get_system,
mock_build_agent_options,
mock_prepare):
settings = [{'name': 'ProcTurboMode', 'value': 'Disabled'},
{'name': 'NicBoot1', 'value': 'NetworkBoot'}]
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
bios = mock_get_system(task.node).bios
bios.apply_time_settings = mock.Mock()
bios.supported_apply_times = ['immediate']
task.driver.bios.apply_configuration(task, settings)
@ -419,7 +417,6 @@ class RedfishBiosTestCase(db_base.DbTestCase):
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
bios = mock_get_system(task.node).bios
bios.apply_time_settings = None
bios.supported_apply_times = [sushy.APPLY_TIME_ON_RESET]
task.driver.bios.apply_configuration(task, settings)
@ -427,3 +424,24 @@ class RedfishBiosTestCase(db_base.DbTestCase):
bios.set_attributes.assert_called_once_with(
{s['name']: s['value'] for s in settings},
apply_time=sushy.APPLY_TIME_ON_RESET)
@mock.patch.object(redfish_boot.RedfishVirtualMediaBoot, 'prepare_ramdisk',
spec_set=True, autospec=True)
@mock.patch.object(deploy_utils, 'build_agent_options', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
@mock.patch.object(manager_utils, 'node_power_action', autospec=True)
def test_apply_configuration_no_supported_apply_times(
self, mock_power_action, mock_get_system, mock_build_agent_options,
mock_prepare):
settings = [{'name': 'ProcTurboMode', 'value': 'Disabled'},
{'name': 'NicBoot1', 'value': 'NetworkBoot'}]
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
bios = mock_get_system(task.node).bios
bios.supported_apply_times = None
task.driver.bios.apply_configuration(task, settings)
bios.set_attributes.assert_called_once_with(
{s['name']: s['value'] for s in settings},
apply_time=None)