summaryrefslogtreecommitdiff
path: root/nova/tests/unit/policies
diff options
context:
space:
mode:
authorBalazs Gibizer <gibi@redhat.com>2022-08-08 19:44:41 +0200
committerSean Mooney <work@seanmooney.info>2022-12-01 18:14:01 +0000
commitb36bc9247ff195d983865860aef8e90bf49334e9 (patch)
treebdd1c38eafefd378f35c02b71feb4b978a5ff5a1 /nova/tests/unit/policies
parent54c7c97cb83609cbcba44856d412dae11fe8643b (diff)
downloadnova-b36bc9247ff195d983865860aef8e90bf49334e9.tar.gz
Remove double mocking... again
I thought we fixed all the double mocking issues with I3998d0d49583806ac1c3ae64f1b1fe343cefd20d but I was wrong. While we used both mock and unittest.mock the fixtures.MockPatch used the mock lib instead of the unittest.mock lib. The path Ibf4f36136f2c65adad64f75d665c00cf2de4b400 (Remove the PowerVM driver) removed the last user of mock lib from nova. So it is also removed the mock from test-requirements. This triggered that fixtures.MockPatch athat started using unittest.mock too. Before Ibf4f36136f2c65adad64f75d665c00cf2de4b400 a function can be mocked twice once with unittest.mock and once with fixtures.MockPatch (still using mock). However after that patch both path of such double mocking goes through unittest.mock and the second one fails. So this patch fixes double mocking so far hidden behind fixtures.MockPatch. This patch made the py310 and functional-py310 jobs voting on master however that has been dropped as part of the backport. Conflicts: nova/tests/fixtures/nova.py nova/tests/unit/api/openstack/compute/test_quotas.py nova/tests/unit/api/openstack/compute/test_server_group_quotas.py Conflicts are due to lack of unified limits feature in xena Change-Id: Ic1352ec31996577a5d0ad18a057339df3e49de25 (cherry picked from commit bf654e3a4a8f690ad0bec0955690bf4fadf98dba) (cherry picked from commit 69667a817cb65c3efbe4e3ada0e8c69c0a106087)
Diffstat (limited to 'nova/tests/unit/policies')
-rw-r--r--nova/tests/unit/policies/test_servers.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/nova/tests/unit/policies/test_servers.py b/nova/tests/unit/policies/test_servers.py
index 33aadb948f..0b98959c49 100644
--- a/nova/tests/unit/policies/test_servers.py
+++ b/nova/tests/unit/policies/test_servers.py
@@ -1230,10 +1230,9 @@ class ServersPolicyTest(base.BasePolicyTest):
@mock.patch('nova.compute.api.API._allow_resize_to_same_host')
@mock.patch('nova.objects.RequestSpec.get_by_instance_uuid')
@mock.patch('nova.objects.Instance.save')
- @mock.patch('nova.api.openstack.common.get_instance')
@mock.patch('nova.conductor.ComputeTaskAPI.resize_instance')
def test_cross_cell_resize_server_policy(
- self, mock_resize, mock_get, mock_save, mock_rs, mock_allow, m_net
+ self, mock_resize, mock_save, mock_rs, mock_allow, m_net
):
# 'migrate' policy is checked before 'resize:cross_cell' so
@@ -1263,7 +1262,7 @@ class ServersPolicyTest(base.BasePolicyTest):
)
return inst
- mock_get.side_effect = fake_get
+ self.mock_get.side_effect = fake_get
def fake_validate(context, instance,
host_name, allow_cross_cell_resize):