Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:too-much-mocking into curtin:master.
Commit message: test_commands_block_meta: do not assert test creates 0 sized partition TestMultipathPartitionHandler.setUp() mocks out the entire util module, which had some unintended consequences that were baked into the test expectations. Scope the mocking better and fix the test's expectations. Requested reviews: curtin developers (curtin-dev) For more details, see: https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/448102 -- Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:too-much-mocking into curtin:master.
diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py index 421b048..2f08f62 100644 --- a/curtin/commands/block_meta.py +++ b/curtin/commands/block_meta.py @@ -1068,6 +1068,7 @@ def partition_handler(info, storage_config, context): length_bytes = util.human2bytes(size) # start sector is part of the sectors that define the partitions size # so length has to be "size in sectors - 1" + print(length_bytes, logical_block_size_bytes) length_sectors = int(length_bytes / logical_block_size_bytes) - 1 # logical partitions can't share their start sector with the extended # partition and logical partitions can't go head-to-head, so we have to diff --git a/tests/unittests/test_commands_block_meta.py b/tests/unittests/test_commands_block_meta.py index f1bc18c..028d04e 100644 --- a/tests/unittests/test_commands_block_meta.py +++ b/tests/unittests/test_commands_block_meta.py @@ -2759,7 +2759,8 @@ class TestMultipathPartitionHandler(CiTestCase): basepath = 'curtin.commands.block_meta.' self.add_patch(basepath + 'get_path_to_storage_volume', 'm_getpath') - self.add_patch(basepath + 'util', 'm_util') + self.add_patch(basepath + 'util.subp', 'm_subp') + self.add_patch(basepath + 'util.del_file', 'm_del_file') self.add_patch(basepath + 'make_dname', 'm_dname') self.add_patch(basepath + 'block', 'm_block') self.add_patch(basepath + 'multipath', 'm_mp') @@ -2813,11 +2814,11 @@ class TestMultipathPartitionHandler(CiTestCase): block_meta.partition_handler(part2, self.storage_config, empty_context) expected_calls = [ - call(['sgdisk', '--new', '2:4096:4096', '--typecode=2:8300', + call(['sgdisk', '--new', '2:4096:10489855', '--typecode=2:8300', disk_path], capture=True), call(['kpartx', '-v', '-a', '-s', '-p', '-part', disk_path]), ] - self.assertEqual(expected_calls, self.m_util.subp.call_args_list) + self.assertEqual(expected_calls, self.m_subp.call_args_list) @patch('curtin.commands.block_meta.os.path') @patch('curtin.commands.block_meta.calc_partition_info') @@ -2842,13 +2843,13 @@ class TestMultipathPartitionHandler(CiTestCase): block_meta.partition_handler(part2, self.storage_config, empty_context) expected_calls = [ - call(['sgdisk', '--new', '2:4096:4096', '--typecode=2:8300', + call(['sgdisk', '--new', '2:4096:10489855', '--typecode=2:8300', disk_path], capture=True), call(['kpartx', '-v', '-a', '-s', '-p', '-part', disk_path]), ] - self.assertEqual(expected_calls, self.m_util.subp.call_args_list) + self.assertEqual(expected_calls, self.m_subp.call_args_list) self.assertEqual([call(disk_path + '-part2')], - self.m_util.del_file.call_args_list) + self.m_del_file.call_args_list) class TestCalcPartitionInfo(CiTestCase):
-- Mailing list: https://launchpad.net/~curtin-dev Post to : curtin-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~curtin-dev More help : https://help.launchpad.net/ListHelp