summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Gibizer <gibi@redhat.com>2022-08-02 18:17:05 +0200
committerBalazs Gibizer <gibi@redhat.com>2022-08-02 18:17:05 +0200
commit6069592bcf9853f12390140d1792a812fa616b12 (patch)
tree5cd667f60f415d8ce021afb4a929d1c1e93d5c83
parentb351f0b848b5e489d31a912e49ae25ea2b38b76c (diff)
downloadnova-6069592bcf9853f12390140d1792a812fa616b12.tar.gz
Fix mocking SafeConnectedTestCase
The recent release of openstacksdk 0.100 showed that our testing is not fully mocking underlying behavior. Such behavior changed in 0.100 and broke our unit test. This patch fixes the mocking to avoid the breakage. Change-Id: Ife4b8b42a414af281ac462faaa42c456ced13bb7
-rw-r--r--nova/tests/unit/scheduler/client/test_report.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/nova/tests/unit/scheduler/client/test_report.py b/nova/tests/unit/scheduler/client/test_report.py
index 288a7530aa..9a1766927c 100644
--- a/nova/tests/unit/scheduler/client/test_report.py
+++ b/nova/tests/unit/scheduler/client/test_report.py
@@ -42,8 +42,14 @@ class SafeConnectedTestCase(test.NoDBTestCase):
super(SafeConnectedTestCase, self).setUp()
self.context = context.get_admin_context()
- with mock.patch('keystoneauth1.loading.load_auth_from_conf_options'):
- self.client = report.SchedulerReportClient()
+ # need to mock this globally as SchedulerReportClient._create_client
+ # is called again when EndpointNotFound is raised
+ self.useFixture(
+ fixtures.MonkeyPatch(
+ 'keystoneauth1.loading.load_auth_from_conf_options',
+ mock.MagicMock()))
+
+ self.client = report.SchedulerReportClient()
@mock.patch('keystoneauth1.session.Session.request')
def test_missing_endpoint(self, req):