tests: Use binary mode to open files

A recent change to the CONTRIBUTING.rst file introduced unicode
characters, which requests does not handle correctly when the file is
open in text mode. requests 3.0 is removing support for opening files in
text mode so we kill two birds with one stone here by switching to
opening the file in binary mode. We also remove the unicode character (I
tested the fix separately), correct the project name in the document,
and use the raise from syntax to get better error handling in these
cases.

Change-Id: I47d65383233e23ec5edf1e6735c39c66eeafb804
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane
2025-08-01 14:32:19 +01:00
parent 1649ed0cda
commit 61323654eb
3 changed files with 10 additions and 5 deletions

View File

@@ -13,11 +13,11 @@ Developer Certificate of Origin
.. index::
single: license; agreement
In order to contribute to the Tacker-Horizon project, you need to adhere
In order to contribute to the openstacksdk project, you need to adhere
to the `Developer Certificate of Origin`_. OpenStack utilizes the Developer
Certificate of Origin (DCO) as a lightweight means to confirm that you are
entitled to contribute the code you submit. This ensures that you are
providing your contributions under the projects license and that you have
providing your contributions under the project's license and that you have
the right to do so.
Please read `DeveloperWorkflow`_ before sending your first patch for review.

View File

@@ -632,7 +632,9 @@ class Proxy(proxy.Proxy):
self.log.debug("Image creation failed", exc_info=True)
raise
except Exception as e:
raise exceptions.SDKException(f"Image creation failed: {str(e)}")
raise exceptions.SDKException(
f"Image creation failed: {str(e)}"
) from e
def _make_v2_image_params(self, meta, properties):
ret: dict = {}
@@ -820,7 +822,7 @@ class Proxy(proxy.Proxy):
raise exceptions.SDKException(
f"Image creation failed: {e.message}",
extra_data=glance_task,
)
) from e
finally:
# Clean up after ourselves. The object we created is not
# needed after the import is done.

View File

@@ -22,6 +22,9 @@ class TestImage(base.BaseImageTest):
def setUp(self):
super().setUp()
with open('CONTRIBUTING.rst', 'rb') as fh:
data = fh.read()
# there's a limit on name length
self.image = self.operator_cloud.image.create_image(
name=TEST_IMAGE_NAME,
@@ -30,7 +33,7 @@ class TestImage(base.BaseImageTest):
properties={
'description': 'This is not an image',
},
data=open('CONTRIBUTING.rst'),
data=data,
)
self.assertIsInstance(self.image, _image.Image)
self.assertEqual(TEST_IMAGE_NAME, self.image.name)