diff options
| author | Zuul <zuul@review.opendev.org> | 2022-03-11 00:40:01 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2022-03-11 00:40:01 +0000 |
| commit | de28b7bfdc35fd38944939a3ca69f950ee762b32 (patch) | |
| tree | b243b4fba9368d653bddc9130a0a5dc7883500a8 /ironic_python_agent/tests/unit/test_hardware.py | |
| parent | 59c02f48ccd543b986d243ceb1dd2214b8c2d1bc (diff) | |
| parent | 99ca1086dbfc7b6e41cf800b0bd899565e2e8922 (diff) | |
| download | ironic-python-agent-de28b7bfdc35fd38944939a3ca69f950ee762b32.tar.gz | |
Merge "Create fstab entry with appropriate label"
Diffstat (limited to 'ironic_python_agent/tests/unit/test_hardware.py')
| -rw-r--r-- | ironic_python_agent/tests/unit/test_hardware.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py index a9deb79b..60820727 100644 --- a/ironic_python_agent/tests/unit/test_hardware.py +++ b/ironic_python_agent/tests/unit/test_hardware.py @@ -66,6 +66,13 @@ RAID_BLK_DEVICE_TEMPLATE_DEVICES = [ vendor="FooTastic", uuid=""), ] +BLK_DEVICE_TEMPLATE_PARTUUID_DEVICE = [ + hardware.BlockDevice(name='/dev/sda1', model='DRIVE 0', + size=107373133824, rotational=True, + vendor="FooTastic", uuid="987654-3210", + partuuid="1234-5678"), +] + class FakeHardwareManager(hardware.GenericHardwareManager): def __init__(self, hardware_support): @@ -4291,6 +4298,25 @@ class TestModuleFunctions(base.IronicAgentTest): self.assertEqual(RAID_BLK_DEVICE_TEMPLATE_DEVICES, result) mocked_udev.assert_called_once_with() + @mock.patch.object(os, 'readlink', autospec=True) + @mock.patch.object(hardware, '_get_device_info', + lambda x, y, z: 'FooTastic') + @mock.patch.object(hardware, '_udev_settle', autospec=True) + @mock.patch.object(hardware.pyudev.Devices, "from_device_file", + autospec=False) + def test_list_all_block_devices_partuuid_success( + self, mocked_fromdevfile, + mocked_udev, mocked_readlink, + mocked_execute): + mocked_readlink.return_value = '../../sda' + mocked_fromdevfile.return_value = {} + mocked_execute.return_value = (hws.PARTUUID_DEVICE_TEMPLATE, '') + result = hardware.list_all_block_devices(block_type='part') + mocked_execute.assert_called_once_with( + 'lsblk', '-Pbia', '-oKNAME,MODEL,SIZE,ROTA,TYPE,UUID,PARTUUID') + self.assertEqual(BLK_DEVICE_TEMPLATE_PARTUUID_DEVICE, result) + mocked_udev.assert_called_once_with() + @mock.patch.object(hardware, '_get_device_info', lambda x, y: "FooTastic") @mock.patch.object(hardware, '_udev_settle', autospec=True) |
