diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index f210267c..8e6e4956 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -1457,7 +1457,8 @@ class FilesystemController(SubiquityController, FilesystemManipulator): rp_input = layout.get("reset-partition", None) if rp_input: reset_partition = True - if isinstance(rp_input, (str, int)): + # bool is a subclass of int -- check for int explicitly + if isinstance(rp_input, str) or type(rp_input) is int: reset_partition_size = int(human2bytes(rp_input)) log.info( "autoinstall: will install reset partition " diff --git a/subiquity/server/controllers/tests/test_filesystem.py b/subiquity/server/controllers/tests/test_filesystem.py index ee2f4d85..4a829a5b 100644 --- a/subiquity/server/controllers/tests/test_filesystem.py +++ b/subiquity/server/controllers/tests/test_filesystem.py @@ -546,6 +546,27 @@ class TestGuided(IsolatedAsyncioTestCase): self.assertEqual(None, d1p2.mount) self.assertEqual(DRY_RUN_RESET_SIZE, d1p2.size) + @parameterized.expand( + ( + ({}, False, None), + ({"reset-partition": True}, True, None), + ({"reset-partition": False}, False, None), + ({"reset-partition": "12345"}, True, 12345), + ({"reset-partition": "10G"}, True, 10737418240), + ({"reset-partition": 100000}, True, 100000), + ) + ) + async def test_rest_partition_size( + self, ai_data, reset_partition, reset_partition_size + ): + await self._guided_setup(Bootloader.UEFI, "gpt") + self.controller.guided = mock.AsyncMock() + layout = ai_data | {"name": "direct"} + await self.controller.run_autoinstall_guided(layout) + guided_choice = self.controller.guided.call_args.args[0] + self.assertEqual(guided_choice.reset_partition, reset_partition) + self.assertEqual(guided_choice.reset_partition_size, reset_partition_size) + async def test_guided_direct_BIOS_MSDOS(self): await self._guided_setup(Bootloader.BIOS, "msdos") target = GuidedStorageTargetReformat(