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:
@@ -13,11 +13,11 @@ Developer Certificate of Origin
|
|||||||
.. index::
|
.. index::
|
||||||
single: license; agreement
|
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
|
to the `Developer Certificate of Origin`_. OpenStack utilizes the Developer
|
||||||
Certificate of Origin (DCO) as a lightweight means to confirm that you are
|
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
|
entitled to contribute the code you submit. This ensures that you are
|
||||||
providing your contributions under the project’s license and that you have
|
providing your contributions under the project's license and that you have
|
||||||
the right to do so.
|
the right to do so.
|
||||||
|
|
||||||
Please read `DeveloperWorkflow`_ before sending your first patch for review.
|
Please read `DeveloperWorkflow`_ before sending your first patch for review.
|
||||||
|
@@ -632,7 +632,9 @@ class Proxy(proxy.Proxy):
|
|||||||
self.log.debug("Image creation failed", exc_info=True)
|
self.log.debug("Image creation failed", exc_info=True)
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
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):
|
def _make_v2_image_params(self, meta, properties):
|
||||||
ret: dict = {}
|
ret: dict = {}
|
||||||
@@ -820,7 +822,7 @@ class Proxy(proxy.Proxy):
|
|||||||
raise exceptions.SDKException(
|
raise exceptions.SDKException(
|
||||||
f"Image creation failed: {e.message}",
|
f"Image creation failed: {e.message}",
|
||||||
extra_data=glance_task,
|
extra_data=glance_task,
|
||||||
)
|
) from e
|
||||||
finally:
|
finally:
|
||||||
# Clean up after ourselves. The object we created is not
|
# Clean up after ourselves. The object we created is not
|
||||||
# needed after the import is done.
|
# needed after the import is done.
|
||||||
|
@@ -22,6 +22,9 @@ class TestImage(base.BaseImageTest):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
|
with open('CONTRIBUTING.rst', 'rb') as fh:
|
||||||
|
data = fh.read()
|
||||||
|
|
||||||
# there's a limit on name length
|
# there's a limit on name length
|
||||||
self.image = self.operator_cloud.image.create_image(
|
self.image = self.operator_cloud.image.create_image(
|
||||||
name=TEST_IMAGE_NAME,
|
name=TEST_IMAGE_NAME,
|
||||||
@@ -30,7 +33,7 @@ class TestImage(base.BaseImageTest):
|
|||||||
properties={
|
properties={
|
||||||
'description': 'This is not an image',
|
'description': 'This is not an image',
|
||||||
},
|
},
|
||||||
data=open('CONTRIBUTING.rst'),
|
data=data,
|
||||||
)
|
)
|
||||||
self.assertIsInstance(self.image, _image.Image)
|
self.assertIsInstance(self.image, _image.Image)
|
||||||
self.assertEqual(TEST_IMAGE_NAME, self.image.name)
|
self.assertEqual(TEST_IMAGE_NAME, self.image.name)
|
||||||
|
Reference in New Issue
Block a user