Skip to content

Commit

Permalink
Merge pull request #512 from mwhudson/lp-1837820
Browse files Browse the repository at this point in the history
fixes for editing existing ESPs
  • Loading branch information
mwhudson authored Jul 25, 2019
2 parents d1fb9c8 + 6084178 commit 6849aea
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
13 changes: 11 additions & 2 deletions subiquity/ui/views/filesystem/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ def __init__(self, parent, disk, partition=None):

if partition.flag != "boot":
initial.update(initial_data_for_fs(self.partition.fs()))
else:
if partition.fs() and partition.fs().mount():
initial['mount'] = '/boot/efi'
else:
initial['mount'] = None
if isinstance(disk, LVM_VolGroup):
initial['name'] = partition.name
lvm_names.remove(partition.name)
Expand Down Expand Up @@ -465,8 +470,12 @@ def done(self, form):
log.debug("Add Partition Result: {}".format(form.as_data()))
data = form.as_data()
if self.partition is not None and self.partition.flag == "boot":
data['fstype'] = self.partition.fs().fstype
data['mount'] = self.partition.fs().mount().path
if self.partition.original_fs() is None:
data['fstype'] = self.partition.fs().fstype
if self.partition.fs().mount() is not None:
data['mount'] = self.partition.fs().mount().path
else:
data['mount'] = None
if isinstance(self.disk, LVM_VolGroup):
handler = self.controller.logical_volume_handler
else:
Expand Down
51 changes: 51 additions & 0 deletions subiquity/ui/views/filesystem/tests/test_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ def test_edit_boot_partition(self):
fs = model.add_filesystem(partition, "fat32")
model.add_mount(fs, '/boot/efi')
view, stretchy = make_partition_view(model, disk, partition)

self.assertFalse(stretchy.form.fstype.enabled)
self.assertEqual(stretchy.form.fstype.value, "fat32")
self.assertFalse(stretchy.form.mount.enabled)
self.assertEqual(stretchy.form.mount.value, "/boot/efi")

view_helpers.enter_data(stretchy.form, form_data)
view_helpers.click(stretchy.form.done_btn.base_widget)
expected_data = {
Expand All @@ -181,6 +187,51 @@ def test_edit_boot_partition(self):
view.controller.partition_disk_handler.assert_called_once_with(
stretchy.disk, stretchy.partition, expected_data)

def test_edit_existing_unused_boot_partition(self):
model, disk = make_model_and_disk()
partition = model.add_partition(disk, 512*(2**20), "boot")
fs = model.add_filesystem(partition, "fat32")
partition._original_fs = fs
disk.preserve = partition.preserve = fs.preserve = True
view, stretchy = make_partition_view(model, disk, partition)

self.assertTrue(stretchy.form.fstype.enabled)
self.assertEqual(stretchy.form.fstype.value, None)
self.assertFalse(stretchy.form.mount.enabled)
self.assertEqual(stretchy.form.mount.value, None)

view_helpers.click(stretchy.form.done_btn.base_widget)
expected_data = {
'fstype': None,
'mount': None,
'use_swap': False,
}
view.controller.partition_disk_handler.assert_called_once_with(
stretchy.disk, stretchy.partition, expected_data)

def test_edit_existing_used_boot_partition(self):
model, disk = make_model_and_disk()
partition = model.add_partition(disk, 512*(2**20), "boot")
fs = model.add_filesystem(partition, "fat32")
partition._original_fs = fs
disk.preserve = partition.preserve = fs.preserve = True
model.add_mount(fs, '/boot/efi')
view, stretchy = make_partition_view(model, disk, partition)

self.assertTrue(stretchy.form.fstype.enabled)
self.assertEqual(stretchy.form.fstype.value, None)
self.assertFalse(stretchy.form.mount.enabled)
self.assertEqual(stretchy.form.mount.value, '/boot/efi')

view_helpers.click(stretchy.form.done_btn.base_widget)
expected_data = {
'fstype': None,
'mount': '/boot/efi',
'use_swap': False,
}
view.controller.partition_disk_handler.assert_called_once_with(
stretchy.disk, stretchy.partition, expected_data)

def test_format_entire_unusual_filesystem(self):
model, disk = make_model_and_disk()
fs = model.add_filesystem(disk, "ntfs")
Expand Down

0 comments on commit 6849aea

Please sign in to comment.