| 1 |
from unittest.mock import ( |
| 2 |
patch, Mock |
| 3 |
) |
| 4 |
from pytest import raises |
| 5 |
|
| 6 |
from kiwi.exceptions import KiwiBootLoaderConfigSetupError |
| 7 |
from kiwi.bootloader.config import create_boot_loader_config |
| 8 |
|
| 9 |
|
| 10 |
class TestBootLoaderConfig: |
| 11 |
def test_bootloader_config_not_implemented(self): |
| 12 |
with raises(KiwiBootLoaderConfigSetupError): |
| 13 |
create_boot_loader_config( |
| 14 |
name='foo', xml_state=Mock(), root_dir='root_dir' |
| 15 |
) |
| 16 |
|
| 17 |
@patch('kiwi.bootloader.config.grub2.BootLoaderConfigGrub2') |
| 18 |
def test_bootloader_config_grub2(self, mock_grub2): |
| 19 |
xml_state = Mock() |
| 20 |
for name in ("grub2", "grub2_s390x_emu"): |
| 21 |
create_boot_loader_config( |
| 22 |
name=name, xml_state=xml_state, root_dir='root_dir' |
| 23 |
) |
| 24 |
mock_grub2.assert_called_once_with( |
| 25 |
xml_state, 'root_dir', None, None |
| 26 |
) |
| 27 |
mock_grub2.reset_mock() |
| 28 |
|
| 29 |
@patch('kiwi.bootloader.config.systemd_boot.BootLoaderSystemdBoot') |
| 30 |
def test_bootloader_config_systemd_boot(self, mock_systemd_boot): |
| 31 |
xml_state = Mock() |
| 32 |
create_boot_loader_config( |
| 33 |
name='systemd_boot', xml_state=xml_state, |
| 34 |
root_dir='root_dir', boot_dir='boot_dir' |
| 35 |
) |
| 36 |
mock_systemd_boot.assert_called_once_with( |
| 37 |
xml_state, 'root_dir', 'boot_dir', None |
| 38 |
) |
| 39 |
|
| 40 |
@patch('kiwi.bootloader.config.zipl.BootLoaderZipl') |
| 41 |
@patch('kiwi.bootloader.config.bootloader_spec_base.FirmWare') |
| 42 |
def test_bootloader_config_zipl(self, mock_FirmWare, mock_zipl): |
| 43 |
xml_state = Mock() |
| 44 |
create_boot_loader_config( |
| 45 |
name='zipl', xml_state=xml_state, |
| 46 |
root_dir='root_dir', boot_dir='boot_dir' |
| 47 |
) |
| 48 |
mock_zipl.assert_called_once_with( |
| 49 |
xml_state, 'root_dir', 'boot_dir', None |
| 50 |
) |
| 51 |
|
| 52 |
@patch('kiwi.bootloader.config.custom.BootLoaderConfigCustom') |
| 53 |
def test_bootloader_config_custom(self, mock_custom): |
| 54 |
xml_state = Mock() |
| 55 |
create_boot_loader_config( |
| 56 |
name='custom', xml_state=xml_state, root_dir='root_dir' |
| 57 |
) |
| 58 |
mock_custom.assert_called_once_with( |
| 59 |
xml_state, 'root_dir', None, None |
| 60 |
) |