diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index e1b9b6b8..822dfbbb 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -331,6 +331,8 @@ class FilesystemModel(ModelPolicy): if disk.usedspace > 0 and "/" in disk.mounts: return True + return False + def bootable(self): ''' true if one disk has a boot partition ''' log.debug('bootable check') diff --git a/subiquity/tests/test_models_filesystems.py b/subiquity/tests/test_models_filesystems.py index 7b3d371c..3772ea50 100644 --- a/subiquity/tests/test_models_filesystems.py +++ b/subiquity/tests/test_models_filesystems.py @@ -142,6 +142,41 @@ class TestFilesystemModel(testtools.TestCase): print(partitions, diskname) self.assertTrue(partitions[0].startswith(diskname)) + def test_filesystemmodel_installable(self): + self.fsm.probe_storage() + self.assertEqual(self.fsm.installable(), False) + + # create a partition that installs to root(/) + diskname = random.choice(list(self.fsm.info.keys())) + disk = self.fsm.get_disk(diskname) + disk.add_partition(1, disk.freespace, 'ext4', '/', flag='bios_grub') + + # now we should be installable + self.assertEqual(self.fsm.installable(), True) + + def test_filesystemmodel_not_installable(self): + self.fsm.probe_storage() + + # create a partition that installs to not root(/) + diskname = random.choice(list(self.fsm.info.keys())) + disk = self.fsm.get_disk(diskname) + disk.add_partition(1, disk.freespace, 'ext4', '/opt', flag='bios_grub') + + # we should not be installable + self.assertEqual(self.fsm.installable(), False) + + def test_filesystemmodel_bootable(self): + self.fsm.probe_storage() + self.assertEqual(self.fsm.bootable(), False) + + # create a partition that installs to root(/) + diskname = random.choice(list(self.fsm.info.keys())) + disk = self.fsm.get_disk(diskname) + disk.add_partition(1, disk.freespace, 'ext4', '/', flag='bios_grub') + + # now we should be installable + self.assertEqual(self.fsm.bootable(), True) + class TestBlockdev(testtools.TestCase): def setUp(self):