From 7fd59da145c76a1f77808ba2e3927e983aaa2b0e Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Wed, 8 Sep 2021 14:30:30 -0400 Subject: [PATCH] Tests: Fix missing RBD delete_volume test case This test intends to test the first rbd.Image() call returning ImageNotFound in the RBD driver's delete_volume method, but was not previously running. Change-Id: Id0d6bc6ec08f0513d5fe8c2ee38a8f49830e6744 --- cinder/tests/unit/volume/drivers/test_rbd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/test_rbd.py b/cinder/tests/unit/volume/drivers/test_rbd.py index 5ccee4eefeb..e3ccb3fe47e 100644 --- a/cinder/tests/unit/volume/drivers/test_rbd.py +++ b/cinder/tests/unit/volume/drivers/test_rbd.py @@ -793,10 +793,13 @@ class RBDTestCase(test.TestCase): 2, drv.rbd.RBD.return_value.trash_move.call_count) @common_mocks - def delete_volume_not_found(self): + def test_delete_volume_not_found_at_open(self): self.mock_rbd.Image.side_effect = self.mock_rbd.ImageNotFound self.assertIsNone(self.driver.delete_volume(self.volume_a)) - self.mock_rbd.Image.assert_called_once_with() + with mock.patch.object(driver, 'RADOSClient') as client: + client = self.mock_client.return_value.__enter__.return_value + self.mock_rbd.Image.assert_called_once_with(client.ioctx, + self.volume_a.name) # Make sure the exception was raised self.assertEqual([self.mock_rbd.ImageNotFound], RAISED_EXCEPTIONS)