kiwi-el8/test/unit/bootloader/config/init_test.py
Dan Čermák f906704ea5
Convert BootLoaderConfig to free function
The class serves really no purpose except for creating another
namespace. This function now allows us to have more stricter type checking.
2024-01-29 13:56:51 +01:00

30 lines
1.2 KiB
Python

from mock import (
patch, Mock
)
from pytest import raises
from kiwi.exceptions import KiwiBootLoaderConfigSetupError
from kiwi.bootloader.config import create_boot_loader_config
class TestBootLoaderConfig:
def test_bootloader_config_not_implemented(self):
with raises(KiwiBootLoaderConfigSetupError):
create_boot_loader_config(name='foo', xml_state=Mock(), root_dir='root_dir')
@patch('kiwi.bootloader.config.grub2.BootLoaderConfigGrub2')
def test_bootloader_config_grub2(self, mock_grub2):
xml_state = Mock()
for name in ("grub2", "grub2_s390x_emu"):
create_boot_loader_config(name=name, xml_state=xml_state, root_dir='root_dir')
mock_grub2.assert_called_once_with(xml_state, 'root_dir', None, None)
mock_grub2.reset_mock()
@patch('kiwi.bootloader.config.systemd_boot.BootLoaderSystemdBoot')
def test_bootloader_config_systemd_boot(self, mock_systemd_boot):
xml_state = Mock()
create_boot_loader_config(name='systemd_boot', xml_state=xml_state, root_dir='root_dir', boot_dir='boot_dir')
mock_systemd_boot.assert_called_once_with(
xml_state, 'root_dir', 'boot_dir', None
)