55from pytest import raises
66import unittest .mock as mock
77
8+ from kiwi .storage .mapped_device import MappedDevice
9+ from kiwi .storage .disk import ptable_entry_type
810from kiwi .bootloader .install .grub2 import BootLoaderInstallGrub2
911from kiwi .defaults import Defaults
1012
1719
1820
1921class TestBootLoaderInstallGrub2 :
20- def setup (self ):
22+ @patch ('os.path.exists' )
23+ def setup (self , mock_os_path_exists ):
24+ mock_os_path_exists .return_value = True
2125 Defaults .set_platform_name ('x86_64' )
2226
2327 self .firmware = mock .Mock ()
2428 self .firmware .efi_mode = mock .Mock (
2529 return_value = None
2630 )
27-
31+ self .device_map = {
32+ 'var' : MappedDevice ('/dev/var-device' , Mock ())
33+ }
2834 self .custom_args = {
35+ 'device_map' : self .device_map ,
2936 'boot_device' : '/dev/mapper/loop0p2' ,
3037 'root_device' : '/dev/mapper/loop0p1' ,
3138 'efi_device' : '/dev/mapper/loop0p3' ,
3239 'prep_device' : '/dev/mapper/loop0p2' ,
3340 'system_root_volume' : 'root' ,
34- 'system_volumes' : {'boot/grub2' : {
35- 'volume_options' : 'subvol=@/boot/grub2' ,
36- 'volume_device' : 'device'
37- }},
41+ 'system_volumes' : {
42+ 'boot/grub2' : {
43+ 'volume_options' : 'subvol=@/boot/grub2' ,
44+ 'volume_device' : 'device'
45+ }
46+ },
47+ 'system_partitions' : {
48+ 'var' : ptable_entry_type (
49+ mbsize = 100 ,
50+ clone = 1 ,
51+ partition_name = 'p.lxvar' ,
52+ partition_type = 't.linux' ,
53+ partition_id = None ,
54+ mountpoint = '/var' ,
55+ filesystem = 'ext3' ,
56+ label = 'var'
57+ )
58+ },
3859 'firmware' : self .firmware ,
3960 'target_removable' : None ,
4061 'install_options' : [],
@@ -49,6 +70,10 @@ def setup(self):
4970 self .volume_mount .device = self .custom_args ['root_device' ]
5071 self .volume_mount .mountpoint = 'tmp_volume'
5172
73+ self .partition_mount = mock .Mock ()
74+ self .partition_mount .device = self .custom_args ['root_device' ]
75+ self .partition_mount .mountpoint = 'tmp_partition'
76+
5277 self .boot_mount = mock .Mock ()
5378 self .boot_mount .device = self .custom_args ['boot_device' ]
5479 self .boot_mount .mountpoint = 'tmp_boot'
@@ -74,6 +99,7 @@ def setup(self):
7499 self .sysfs_mount ,
75100 self .proc_mount ,
76101 self .device_mount ,
102+ self .partition_mount ,
77103 self .volume_mount ,
78104 self .efi_mount ,
79105 self .boot_mount ,
@@ -357,6 +383,7 @@ def side_effect(device, mountpoint=None):
357383 self .root_mount .mount .assert_called_once_with (
358384 options = ['subvol=root' ]
359385 )
386+ self .partition_mount .mount .assert_called_once_with ()
360387 self .volume_mount .mount .assert_called_once_with (
361388 options = ['subvol=@/boot/grub2' ]
362389 )
@@ -421,6 +448,7 @@ def side_effect(device, mountpoint=None):
421448 self .root_mount .mount .assert_called_once_with (
422449 options = ['subvol=root' ]
423450 )
451+ self .partition_mount .mount .assert_called_once_with ()
424452 self .volume_mount .mount .assert_called_once_with (
425453 options = ['subvol=@/boot/grub2' ]
426454 )
@@ -446,6 +474,7 @@ def side_effect(device, mountpoint=None):
446474 self .root_mount .mount .assert_called_once_with (
447475 options = ['subvol=root' ]
448476 )
477+ self .partition_mount .mount .assert_called_once_with ()
449478 self .volume_mount .mount .assert_called_once_with (
450479 options = ['subvol=@/boot/grub2' ]
451480 )
0 commit comments