diff --git a/blivetgui/dialogs/add_dialog.py b/blivetgui/dialogs/add_dialog.py index a7b5e51c..55bc0284 100644 --- a/blivetgui/dialogs/add_dialog.py +++ b/blivetgui/dialogs/add_dialog.py @@ -790,12 +790,19 @@ def add_fs_chooser(self): return filesystems_store, filesystems_combo + def _allow_format_size(self, fs): + # FIXME: also check raid level -- resulting "free space" might be lower because of redundancy + if self.selected_free.size < fs._min_size: + return False + if self.size_area and fs._max_size and self.size_area.min_size > fs._max_size: + return False + return True + def update_fs_chooser(self): self.filesystems_store.clear() for fs in self.supported_filesystems: - # FIXME: also check raid level -- resulting "free space" might be lower because of redundancy - if self.selected_free.size > fs._min_size: + if self._allow_format_size(fs): self.filesystems_store.append((fs, fs.type, fs.name)) self.filesystems_store.append((None, "unformatted", _("unformatted"))) diff --git a/tests/blivetgui_tests/add_dialog_test.py b/tests/blivetgui_tests/add_dialog_test.py index 45b2eccf..4b465025 100644 --- a/tests/blivetgui_tests/add_dialog_test.py +++ b/tests/blivetgui_tests/add_dialog_test.py @@ -251,7 +251,8 @@ def _get_free_device(self, size=Size("8 GiB"), logical=False, parent=None, **kwa uninitialized_disk = kwargs.get("is_uninitialized_disk", False) return MagicMock(type="free_space", size=size, is_logical=logical, parents=[parent], disk=parent, - is_free_region=free_region, is_empty_disk=empty_disk, is_uninitialized_disk=uninitialized_disk) + is_free_region=free_region, is_empty_disk=empty_disk, is_uninitialized_disk=uninitialized_disk, + min_size=kwargs.get("min_size", Size("1 MiB"))) def _get_parent_device(self, name=None, dtype="disk", size=Size("8 GiB"), ftype="disklabel"): if not name: @@ -261,17 +262,19 @@ def _get_parent_device(self, name=None, dtype="disk", size=Size("8 GiB"), ftype= name = "fedora" dev = MagicMock() - dev.configure_mock(name=name, type=dtype, size=size, - format=MagicMock(type=ftype, - sector_size=512, - parted_disk=MagicMock(maxPartitionLength=4294967295))) - if dtype != "disk": + dev.configure_mock(name=name, type=dtype, size=size) + + if dtype == "disk": + dev.configure_mock(format=MagicMock(type=ftype, + sector_size=512, + parted_disk=MagicMock(maxPartitionLength=4294967295))) + else: disk = self._get_parent_device() - dev.configure_mock(disk=disk, parents=[disk]) + dev.configure_mock(disk=disk, parents=[disk], format=MagicMock(type=ftype)) if dtype == "lvmvg": pv = MagicMock() disk = self._get_parent_device() - pv.configure_mock(name="vda1", size=size, format=MagicMock(free=size), disk=disk, parents=[disk]) + pv.configure_mock(name="vda1", size=size, format=MagicMock(type="lvmpv", free=size), disk=disk, parents=[disk]) dev.configure_mock(pe_size=Size("4 MiB"), free_space=size, pvs=[pv], parents=[pv], pmspare_size=Size("4 MiB")) @@ -559,6 +562,20 @@ def test_fs_chooser_biosboot(self): add_dialog.filesystems_combo.set_active_id("ext4") self.assertEqual(add_dialog.filesystems_combo.get_active_id(), "ext4") + # check that biosboot is not available when creating lv (rhbz#2318274) + parent_device = self._get_parent_device(dtype="lvmvg", ftype=None) + free_device = self._get_free_device(parent=parent_device, min_size=Size("4 MiB")) + _filesystems = self.supported_filesystems[:] + _filesystems.append(formats.biosboot.BIOSBoot()) + + add_dialog = AddDialog(self.parent_window, parent_device, free_device, + [("free", free_device)], _filesystems, + []) + add_dialog.devices_combo.set_active_id("lvmlv") + + ret = add_dialog.filesystems_combo.set_active_id("biosboot") + self.assertFalse(ret) + def test_md_type(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device)