rpm-packaging/openstack/python-glanceclient/0001-Fix-unit-tests-broken-by-requests-mock-1.12.0.patch
Dirk Müller bdc0b11dd1
Add patch for compatibility with newer requests-mock
Change-Id: Ie6a888f1fc45b834811714c65fd705bed739a55e
2024-05-06 12:31:34 +02:00

46 lines
1.6 KiB
Diff

From 300b8c8262d8dcdca7a8d753c3fb8a22cae02d40 Mon Sep 17 00:00:00 2001
From: Takashi Kajinami <kajinamit@oss.nttdata.com>
Date: Sun, 28 Apr 2024 22:19:24 +0900
Subject: [PATCH] Fix unit tests broken by requests-mock >= 1.12.0
requests-mock removed the old compatibility code in 1.12.0[1] and now
usage of a bare dict for response header causes AttributeError.
[1] https://github.com/jamielennox/requests-mock/commit/e3bd0d1a92e40fa9cb1d587c59157020a45de620
Closes-Bug: #2064011
Change-Id: Iee86fa3eae86102112987b8648ada73d37ac58e8
---
glanceclient/tests/utils.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/glanceclient/tests/utils.py b/glanceclient/tests/utils.py
index 730b928..750fb7e 100644
--- a/glanceclient/tests/utils.py
+++ b/glanceclient/tests/utils.py
@@ -14,6 +14,7 @@
# under the License.
import copy
+from email.message import EmailMessage
import io
import json
import testtools
@@ -112,7 +113,12 @@ class FakeResponse(object):
self.body = body
self.reason = reason
self.version = version
- self.headers = headers
+ # NOTE(tkajinam): Make the FakeResponse class compatible with
+ # http.client.HTTPResponse
+ # https://docs.python.org/3/library/http.client.html
+ self.headers = EmailMessage()
+ for header_key in headers:
+ self.headers[header_key] = headers[header_key]
self.headers['x-openstack-request-id'] = 'req-1234'
self.status_code = status_code
self.raw = RawRequest(headers, body=body, reason=reason,
--
2.44.0