Merge "Fix FakeBIOS to allow tempest testing"

This commit is contained in:
Zuul 2018-06-05 09:28:01 +00:00 committed by Gerrit Code Review
commit 097be73f33
4 changed files with 11 additions and 5 deletions

View File

@ -953,7 +953,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)