Fix FakeBIOS to allow tempest testing

In order to start tempest testing using FakeBIOS, we
need to fix some issues, like enabling it on the fake
driver, and add the clean_steps decorators.

Change-Id: I7c47187b823c3a0ce1784849d401bd6baafe2542
This commit is contained in:
Yolanda Robla 2018-05-31 12:50:06 +02:00
parent 01ae88db37
commit 4bc142e0dc
4 changed files with 11 additions and 5 deletions

View File

@ -937,7 +937,7 @@ class BIOSInterface(BaseInterface):
def wrapper(func):
@six.wraps(func)
def wrapped(self, task, *args, **kwargs):
def wrapped(task, *args, **kwargs):
func(task, *args, **kwargs)
instance.cache_bios_settings(task)
return wrapped

View File

@ -246,6 +246,10 @@ class FakeBIOS(base.BIOSInterface):
def validate(self, task):
pass
@base.clean_step(priority=0, argsinfo={
'settings': {'description': ('List of BIOS settings, each item needs '
'to contain a dictionary with name/value pairs'),
'required': True}})
def apply_configuration(self, task, settings):
node_id = task.node.id
try:
@ -253,6 +257,7 @@ class FakeBIOS(base.BIOSInterface):
except exception.BIOSSettingAlreadyExists:
objects.BIOSSettingList.save(task.context, node_id, settings)
@base.clean_step(priority=0)
def factory_reset(self, task):
node_id = task.node.id
setting_objs = objects.BIOSSettingList.get_by_node_id(
@ -260,6 +265,7 @@ class FakeBIOS(base.BIOSInterface):
for setting in setting_objs:
objects.BIOSSetting.delete(task.context, node_id, setting.name)
@base.clean_step(priority=0)
def cache_bios_settings(self, task):
pass

View File

@ -36,10 +36,10 @@ class NoInterfacesTestCase(base.TestCase):
def test_bios(self):
self.assertRaises(exception.UnsupportedDriverExtension,
getattr(noop.NoBIOS(), 'apply_configuration'),
self, self.task, '')
self.task, '')
self.assertRaises(exception.UnsupportedDriverExtension,
getattr(noop.NoBIOS(), 'factory_reset'),
self, self.task)
self.task)
def test_console(self):
for method in ('start_console', 'stop_console', 'get_console'):

View File

@ -447,7 +447,7 @@ class TestBIOSInterface(base.TestCase):
bios = MyBIOSInterface()
task_mock = mock.MagicMock()
bios.apply_configuration(bios, task_mock, "")
bios.apply_configuration(task_mock, "")
cache_bios_settings_mock.assert_called_once_with(bios, task_mock)
@mock.patch.object(MyBIOSInterface, 'cache_bios_settings', autospec=True)
@ -455,7 +455,7 @@ class TestBIOSInterface(base.TestCase):
bios = MyBIOSInterface()
task_mock = mock.MagicMock()
bios.factory_reset(bios, task_mock)
bios.factory_reset(task_mock)
cache_bios_settings_mock.assert_called_once_with(bios, task_mock)