summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIury Gregory Melo Ferreira <iurygregory@gmail.com>2021-11-25 11:05:55 +0100
committerIury Gregory Melo Ferreira <iurygregory@gmail.com>2021-11-25 11:21:32 +0100
commit4042e7b08cf18a44d62bcc6580027aa8d228a23a (patch)
tree9ccf8068f16346694e773c6cdfbb86813389e38e
parentbcf284655363b9b5a7e567cd2ccba61398facb06 (diff)
downloadironic-python-agent-4042e7b08cf18a44d62bcc6580027aa8d228a23a.tar.gz
Get rid of lambda in RealFilePartitioningTestCase
This commit changes the lambda usage in the RealFilePartitioningTestCase to autospec to avoid problems with unexpected args. Change-Id: I21356a7783f105dde9ff0d3777e2a06f3f28a786
-rw-r--r--ironic_python_agent/tests/unit/test_partition_utils.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/ironic_python_agent/tests/unit/test_partition_utils.py b/ironic_python_agent/tests/unit/test_partition_utils.py
index 1bae6d15..f6f56695 100644
--- a/ironic_python_agent/tests/unit/test_partition_utils.py
+++ b/ironic_python_agent/tests/unit/test_partition_utils.py
@@ -1097,15 +1097,15 @@ class CreateConfigDriveTestCases(base.IronicAgentTest):
# NOTE(TheJulia): trigger_device_rescan is systemwide thus pointless
# to execute in the file test case. Also, CI unit test jobs lack sgdisk.
-@mock.patch.object(disk_utils, 'trigger_device_rescan', lambda *_: None)
-@mock.patch.object(utils, 'wait_for_disk_to_become_available', lambda *_: None)
-@mock.patch.object(disk_utils, 'is_block_device', lambda d: True)
-@mock.patch.object(disk_utils, 'block_uuid', lambda p: 'uuid')
-@mock.patch.object(disk_utils, 'dd', lambda *_: None)
-@mock.patch.object(disk_utils, 'convert_image', lambda *_: None)
-@mock.patch.object(utils, 'mkfs', lambda fs, path, label=None: None)
+@mock.patch.object(disk_utils, 'trigger_device_rescan', autospec=True)
+@mock.patch.object(utils, 'wait_for_disk_to_become_available', autospec=True)
+@mock.patch.object(disk_utils, 'is_block_device', autospec=True)
+@mock.patch.object(disk_utils, 'block_uuid', autospec=True)
+@mock.patch.object(disk_utils, 'dd', autospec=True)
+@mock.patch.object(disk_utils, 'convert_image', autospec=True)
+@mock.patch.object(utils, 'mkfs', autospec=True)
# NOTE(dtantsur): destroy_disk_metadata resets file size, disabling it
-@mock.patch.object(disk_utils, 'destroy_disk_metadata', lambda *_: None)
+@mock.patch.object(disk_utils, 'destroy_disk_metadata', autospec=True)
class RealFilePartitioningTestCase(base.IronicAgentTest):
"""This test applies some real-world partitioning scenario to a file.
@@ -1143,7 +1143,9 @@ class RealFilePartitioningTestCase(base.IronicAgentTest):
with mock.patch.object(utils, 'execute', fake_execute):
return func(*args, **kwargs)
- def test_different_sizes(self):
+ def test_different_sizes(self, mock_destroy, mock_mkfs, mock_convert,
+ mock_dd, mock_block_uuid, mock_is_block,
+ mock_wait, mock_trigger_rescan):
# NOTE(dtantsur): Keep this list in order with expected partitioning
fields = ['ephemeral_mb', 'swap_mb', 'root_mb']
variants = ((0, 0, 12), (4, 2, 8), (0, 4, 10), (5, 0, 10))
@@ -1158,7 +1160,9 @@ class RealFilePartitioningTestCase(base.IronicAgentTest):
self.assertEqual(expected_size, part['size'],
"comparison failed for %s" % list(variant))
- def test_whole_disk(self):
+ def test_whole_disk(self, mock_destroy, mock_mkfs, mock_convert, mock_dd,
+ mock_block_uuid, mock_is_block, mock_wait,
+ mock_trigger_rescan):
# 6 MiB ephemeral + 3 MiB swap + 9 MiB root + 1 MiB for MBR
# + 1 MiB MAGIC == 20 MiB whole disk
# TODO(dtantsur): figure out why we need 'magic' 1 more MiB