From f55144780441c37310174b20afd4cf3b8efdae04 Mon Sep 17 00:00:00 2001 From: Alexey Stupnikov Date: Wed, 1 Jun 2022 14:13:12 +0200 Subject: [PATCH] Optimize _local_delete calls by compute unit tests _fake_do_delete function from nova/tests/unit/compute/test_api.py is called with reservations=None argument. This argument is no longer used in _local_delete. Since_fake_do_delete function is not really used because it only contains pass statement, we can replace it with no op call implemented using lambda function. Change-Id: Idf9686afeadc2d000c3bc255e809c914967a063f --- nova/tests/unit/compute/test_api.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nova/tests/unit/compute/test_api.py b/nova/tests/unit/compute/test_api.py index b41ec19cb1..b2b01772b5 100644 --- a/nova/tests/unit/compute/test_api.py +++ b/nova/tests/unit/compute/test_api.py @@ -1353,10 +1353,6 @@ class _ComputeAPIUnitTestMixIn(object): self.context, instance_uuid, constraint='constraint', hard_delete=False) - def _fake_do_delete(context, instance, bdms, - reservations=None, local=False): - pass - @mock.patch.object(compute_utils, 'notify_about_instance_action') @mock.patch.object(objects.BlockDeviceMapping, 'destroy') @mock.patch.object(cinder.API, 'detach') @@ -1378,9 +1374,11 @@ class _ComputeAPIUnitTestMixIn(object): mock_elevated.return_value = self.context mock_detach.side_effect = exception.VolumeNotFound('volume_id') + # lambda function is used to run no op call as a delete function + # called by compute_api._local_delete self.compute_api._local_delete(self.context, inst, bdms, 'delete', - self._fake_do_delete) + lambda *args, **kwargs: None) mock_notify_legacy.assert_has_calls([ mock.call(self.compute_api.notifier, self.context, @@ -1416,8 +1414,11 @@ class _ComputeAPIUnitTestMixIn(object): inst._context = self.context mock_elevated.return_value = self.context bdms = [] + # lambda function is used to run no op call as a delete function + # called by compute_api._local_delete self.compute_api._local_delete(self.context, inst, bdms, - 'delete', self._fake_do_delete) + 'delete', + lambda *args, **kwargs: None) mock_del_arqs.assert_called_once_with(self.context, inst) @mock.patch.object(objects.BlockDeviceMapping, 'destroy')