From 6f42768756db503e7ef9152b35c0e106b87c5be0 Mon Sep 17 00:00:00 2001 From: Kaifeng Wang Date: Wed, 24 Oct 2018 10:48:27 +0800 Subject: [PATCH] Follow up to parallel disk erasure Improve test to verify apply_async is called twice as expected. Story: 1546949 Task: 11548 Change-Id: I41736dfb2932dd0036bbc4cbc51929bf61a16569 --- ironic_python_agent/tests/unit/test_hardware.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py index 316493d5e..2f66f1376 100644 --- a/ironic_python_agent/tests/unit/test_hardware.py +++ b/ironic_python_agent/tests/unit/test_hardware.py @@ -1308,17 +1308,19 @@ class TestGenericHardwareManager(base.IronicAgentTest): apply_result.get = lambda: 'erased device' mocked_async.return_value = apply_result + blkdev1 = hardware.BlockDevice('/dev/sdj', 'big', 1073741824, True) + blkdev2 = hardware.BlockDevice('/dev/hdaa', 'small', 65535, False) self.hardware.list_block_devices = mock.Mock() - self.hardware.list_block_devices.return_value = [ - hardware.BlockDevice('/dev/sdj', 'big', 1073741824, True), - hardware.BlockDevice('/dev/hdaa', 'small', 65535, False), - ] + self.hardware.list_block_devices.return_value = [blkdev1, blkdev2] expected = {'/dev/hdaa': 'erased device', '/dev/sdj': 'erased device'} result = self.hardware.erase_devices(self.node, []) - self.assertTrue(mocked_async.called) + calls = [mock.call(mock.ANY, mocked_dispatch, ('erase_block_device',), + {'node': self.node, 'block_device': dev}) + for dev in (blkdev1, blkdev2)] + mocked_async.assert_has_calls(calls) self.assertEqual(expected, result) @mock.patch.object(hardware, 'ThreadPool', autospec=True)