Check status code when downloading empty file
According to
https://developer.openstack.org/api-ref/image/v2/#download-binary-image-data
The status code of Glance API is 204 when downloading empty file, so
this patch adds the corresponding check on a test.
This patch comes from I6eef7231742d873a0e727c300a9ae7f5958ac4f8
Change-Id: Ia45b584e3783c6ab6d7c94a817da9b5058f1c351
Related-Bug: #1756264
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index ce5bd3e..aa57daf 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -71,8 +71,12 @@
self.assertEqual(1024, body.get('size'))
# Now try get image file
+ # NOTE: This Glance API returns different status codes for image
+ # condition. In this non-empty data case, Glance should return 200,
+ # so here should check the status code.
body = self.client.show_image_file(image['id'])
self.assertEqual(file_content, body.data)
+ self.assertEqual(200, body.response.status)
@decorators.attr(type='smoke')
@decorators.idempotent_id('f848bb94-1c6e-45a4-8726-39e3a5b23535')
@@ -111,6 +115,13 @@
visibility='private')
self.assertEqual('queued', image['status'])
+ # NOTE: This Glance API returns different status codes for image
+ # condition. In this empty data case, Glance should return 204,
+ # so here should check the status code.
+ image_file = self.client.show_image_file(image['id'])
+ self.assertEqual(0, len(image_file.data))
+ self.assertEqual(204, image_file.response.status)
+
# Now try uploading an image file
image_file = six.BytesIO(data_utils.random_bytes())
self.client.store_image_file(image['id'], image_file)