| 1 |
# vim: set fileencoding=utf-8 |
| 2 |
from unittest.mock import patch |
| 3 |
|
| 4 |
import os |
| 5 |
|
| 6 |
from kiwi.system.profile import Profile |
| 7 |
from kiwi.xml_state import XMLState |
| 8 |
from kiwi.xml_description import XMLDescription |
| 9 |
|
| 10 |
|
| 11 |
class TestProfile: |
| 12 |
def setup(self): |
| 13 |
self.profile_file = 'tmpfile.profile' |
| 14 |
description = XMLDescription('../data/example_dot_profile_config.xml') |
| 15 |
self.profile = Profile( |
| 16 |
XMLState(description.load()) |
| 17 |
) |
| 18 |
live_description = XMLDescription( |
| 19 |
'../data/example_dot_profile_live_config.xml' |
| 20 |
) |
| 21 |
self.live_profile = Profile( |
| 22 |
XMLState(live_description.load()) |
| 23 |
) |
| 24 |
|
| 25 |
def setup_method(self, cls): |
| 26 |
self.setup() |
| 27 |
|
| 28 |
@patch('kiwi.path.Path.which') |
| 29 |
def test_create_live(self, mock_which): |
| 30 |
mock_which.side_effect = ['cp', 'bash'] |
| 31 |
self.live_profile.create(self.profile_file) |
| 32 |
os.remove(self.profile_file) |
| 33 |
assert self.live_profile.dot_profile == { |
| 34 |
'kiwi_iname': 'LiveImage', |
| 35 |
'kiwi_displayname': 'Live', |
| 36 |
'kiwi_profiles': '', |
| 37 |
'kiwi_delete': '', |
| 38 |
'kiwi_type': 'iso', |
| 39 |
'kiwi_compressed': None, |
| 40 |
'kiwi_boot_timeout': None, |
| 41 |
'kiwi_wwid_wait_timeout': None, |
| 42 |
'kiwi_hybridpersistent': True, |
| 43 |
'kiwi_hybridpersistent_filesystem': 'ext4', |
| 44 |
'kiwi_initrd_system': 'dracut', |
| 45 |
'kiwi_ramonly': None, |
| 46 |
'kiwi_target_blocksize': '512', |
| 47 |
'kiwi_target_removable': None, |
| 48 |
'kiwi_cmdline': 'console=ttyS0', |
| 49 |
'kiwi_firmware': 'bios', |
| 50 |
'kiwi_bootloader': 'grub2', |
| 51 |
'kiwi_bootloader_console': 'default:default', |
| 52 |
'kiwi_btrfs_root_is_snapshot': None, |
| 53 |
'kiwi_btrfs_root_is_snapper_snapshot': None, |
| 54 |
'kiwi_gpt_hybrid_mbr': None, |
| 55 |
'kiwi_devicepersistency': None, |
| 56 |
'kiwi_installboot': None, |
| 57 |
'kiwi_bootkernel': None, |
| 58 |
'kiwi_fsmountoptions': None, |
| 59 |
'kiwi_bootprofile': None, |
| 60 |
'kiwi_vga': 'auto', |
| 61 |
'kiwi_startsector': 2048, |
| 62 |
'kiwi_luks_empty_passphrase': False, |
| 63 |
'kiwi_live_volid': 'CDROM', |
| 64 |
'kiwi_iversion': '1.1.0', |
| 65 |
'kiwi_showlicense': None, |
| 66 |
'kiwi_keytable': 'us.map.gz', |
| 67 |
'kiwi_timezone': 'Europe/Berlin', |
| 68 |
'kiwi_language': 'en_US', |
| 69 |
'kiwi_strip_delete': '', |
| 70 |
'kiwi_strip_tools': '', |
| 71 |
'kiwi_strip_libs': '', |
| 72 |
'kiwi_drivers': '', |
| 73 |
'kiwi_rootpartuuid': None, |
| 74 |
'kiwi_shasum_suffix': '.sha256' |
| 75 |
} |
| 76 |
|
| 77 |
@patch('kiwi.path.Path.which') |
| 78 |
def test_create_oem(self, mock_which): |
| 79 |
mock_which.side_effect = ['cp', 'bash'] |
| 80 |
self.profile.create(self.profile_file) |
| 81 |
os.remove(self.profile_file) |
| 82 |
assert self.profile.dot_profile == { |
| 83 |
'kiwi_Volume_1': 'usr_lib|size:1024|usr/lib', |
| 84 |
'kiwi_Volume_2': 'etc_volume|freespace:30|etc', |
| 85 |
'kiwi_Volume_3': 'bin_volume|size:all|/usr/bin', |
| 86 |
'kiwi_Volume_4': 'usr_bin|freespace:30|usr/bin', |
| 87 |
'kiwi_Volume_5': 'LVSwap|size:128|', |
| 88 |
'kiwi_Volume_Root': 'LVRoot|freespace:500|', |
| 89 |
'kiwi_bootkernel': None, |
| 90 |
'kiwi_bootloader': 'grub2', |
| 91 |
'kiwi_bootprofile': None, |
| 92 |
'kiwi_target_removable': None, |
| 93 |
'kiwi_boot_timeout': None, |
| 94 |
'kiwi_cmdline': 'splash', |
| 95 |
'kiwi_compressed': None, |
| 96 |
'kiwi_delete': '', |
| 97 |
'kiwi_devicepersistency': None, |
| 98 |
'kiwi_bootloader_console': 'default:default', |
| 99 |
'kiwi_displayname': 'schäfer', |
| 100 |
'kiwi_drivers': '', |
| 101 |
'kiwi_firmware': 'efi', |
| 102 |
'kiwi_fsmountoptions': None, |
| 103 |
'kiwi_hybridpersistent_filesystem': None, |
| 104 |
'kiwi_hybridpersistent': None, |
| 105 |
'kiwi_iname': 'LimeJeOS-openSUSE-13.2', |
| 106 |
'kiwi_installboot': None, |
| 107 |
'kiwi_iversion': '1.13.2', |
| 108 |
'kiwi_keytable': 'us.map.gz', |
| 109 |
'kiwi_language': 'en_US', |
| 110 |
'kiwi_loader_theme': 'openSUSE', |
| 111 |
'kiwi_lvm': 'true', |
| 112 |
'kiwi_lvmgroup': 'systemVG', |
| 113 |
'kiwi_oembootwait': None, |
| 114 |
'kiwi_oemramdisksize': None, |
| 115 |
'kiwi_oemdevicefilter': None, |
| 116 |
'kiwi_oemnicfilter': None, |
| 117 |
'kiwi_oemkboot': None, |
| 118 |
'kiwi_oemmultipath_scan': None, |
| 119 |
'kiwi_oempartition_install': None, |
| 120 |
'kiwi_oemrebootinteractive': None, |
| 121 |
'kiwi_oemreboot': None, |
| 122 |
'kiwi_oemrecoveryID': None, |
| 123 |
'kiwi_oemrecoveryInPlace': None, |
| 124 |
'kiwi_oemrecovery': False, |
| 125 |
'kiwi_oemrecoveryPartSize': None, |
| 126 |
'kiwi_oemrootMB': 2048, |
| 127 |
'kiwi_oemshutdowninteractive': None, |
| 128 |
'kiwi_oemresizeonce': None, |
| 129 |
'kiwi_oemshutdown': None, |
| 130 |
'kiwi_oemsilentboot': None, |
| 131 |
'kiwi_oemsilentinstall': None, |
| 132 |
'kiwi_oemsilentverify': None, |
| 133 |
'kiwi_oemskipverify': 'true', |
| 134 |
'kiwi_oemswapMB': None, |
| 135 |
'kiwi_oemtitle': 'schäfer', |
| 136 |
'kiwi_oemunattended_id': None, |
| 137 |
'kiwi_oemunattended': None, |
| 138 |
'kiwi_oemvmcp_parmfile': None, |
| 139 |
'kiwi_profiles': '', |
| 140 |
'kiwi_ramonly': True, |
| 141 |
'kiwi_initrd_system': 'dracut', |
| 142 |
'kiwi_install_volid': 'INSTALL', |
| 143 |
'kiwi_btrfs_root_is_snapshot': None, |
| 144 |
'kiwi_btrfs_root_is_snapper_snapshot': None, |
| 145 |
'kiwi_gpt_hybrid_mbr': None, |
| 146 |
'kiwi_showlicense': None, |
| 147 |
'kiwi_splash_theme': 'openSUSE', |
| 148 |
'kiwi_strip_delete': '', |
| 149 |
'kiwi_strip_libs': '', |
| 150 |
'kiwi_strip_tools': '', |
| 151 |
'kiwi_target_blocksize': '512', |
| 152 |
'kiwi_timezone': 'Europe/Berlin', |
| 153 |
'kiwi_type': 'oem', |
| 154 |
'kiwi_vga': 'auto', |
| 155 |
'kiwi_startsector': 2048, |
| 156 |
'kiwi_luks_empty_passphrase': True, |
| 157 |
'kiwi_wwid_wait_timeout': None, |
| 158 |
'kiwi_xendomain': 'dom0', |
| 159 |
'kiwi_rootpartuuid': None, |
| 160 |
'kiwi_shasum_suffix': '.sha256' |
| 161 |
} |
| 162 |
|
| 163 |
@patch('kiwi.path.Path.which') |
| 164 |
def test_create_displayname_is_image_name(self, mock_which): |
| 165 |
mock_which.side_effect = ['cp', 'bash'] |
| 166 |
description = XMLDescription('../data/example_pxe_config.xml') |
| 167 |
profile = Profile( |
| 168 |
XMLState(description.load()) |
| 169 |
) |
| 170 |
profile.create(self.profile_file) |
| 171 |
os.remove(self.profile_file) |
| 172 |
assert profile.dot_profile['kiwi_displayname'] == \ |
| 173 |
'LimeJeOS-openSUSE-13.2' |
| 174 |
|
| 175 |
@patch('kiwi.path.Path.which') |
| 176 |
def test_create_cpio(self, mock_which): |
| 177 |
mock_which.side_effect = ['cp', 'bash'] |
| 178 |
description = XMLDescription('../data/example_dot_profile_config.xml') |
| 179 |
profile = Profile( |
| 180 |
XMLState(description.load(), None, 'cpio') |
| 181 |
) |
| 182 |
profile.create(self.profile_file) |
| 183 |
os.remove(self.profile_file) |
| 184 |
assert profile.dot_profile['kiwi_cpio_name'] == \ |
| 185 |
'LimeJeOS-openSUSE-13.2' |
| 186 |
|
| 187 |
def test_add(self): |
| 188 |
self.profile.add('foo', 'bar') |
| 189 |
assert self.profile.dot_profile['foo'] == 'bar' |
| 190 |
|
| 191 |
def test_delete(self): |
| 192 |
self.profile.add('foo', 'bar') |
| 193 |
self.profile.delete('foo') |
| 194 |
assert 'foo' not in self.profile.dot_profile |