storage/v2: decline a second add_boot_partition
This commit is contained in:
parent
39b6c428ac
commit
5181e4a4ac
|
@ -330,6 +330,8 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
||||||
|
|
||||||
async def v2_add_boot_partition_POST(self, disk_id: str) \
|
async def v2_add_boot_partition_POST(self, disk_id: str) \
|
||||||
-> StorageResponseV2:
|
-> StorageResponseV2:
|
||||||
|
if not self.model.needs_bootloader_partition():
|
||||||
|
raise ValueError('device already has bootloader partition')
|
||||||
disk = self.model._one(id=disk_id)
|
disk = self.model._one(id=disk_id)
|
||||||
if DeviceAction.TOGGLE_BOOT not in DeviceAction.supported(disk):
|
if DeviceAction.TOGGLE_BOOT not in DeviceAction.supported(disk):
|
||||||
raise ValueError("disk does not support boot partiton")
|
raise ValueError("disk does not support boot partiton")
|
||||||
|
|
|
@ -286,6 +286,15 @@ class TestAdd(TestAPI):
|
||||||
manual_add = await inst.post('/storage/v2/add_partition', data)
|
manual_add = await inst.post('/storage/v2/add_partition', data)
|
||||||
self.assertEqual(single_add, manual_add)
|
self.assertEqual(single_add, manual_add)
|
||||||
|
|
||||||
|
@timeout(5)
|
||||||
|
async def test_v2_deny_multiple_add_boot_partition(self):
|
||||||
|
async with start_server('examples/simple.json') as inst:
|
||||||
|
disk_id = 'disk-sda'
|
||||||
|
await inst.post('/storage/v2/add_boot_partition', disk_id=disk_id)
|
||||||
|
with self.assertRaises(ClientResponseError):
|
||||||
|
await inst.post('/storage/v2/add_boot_partition',
|
||||||
|
disk_id=disk_id)
|
||||||
|
|
||||||
@timeout(5)
|
@timeout(5)
|
||||||
async def test_v2_free_for_partitions(self):
|
async def test_v2_free_for_partitions(self):
|
||||||
async with start_server('examples/simple.json') as inst:
|
async with start_server('examples/simple.json') as inst:
|
||||||
|
|
Loading…
Reference in New Issue