Merge "Loosen constraints on Swift status codes."
diff --git a/tempest/api/object_storage/test_account_services.py b/tempest/api/object_storage/test_account_services.py
index b40774e..029f2d5 100644
--- a/tempest/api/object_storage/test_account_services.py
+++ b/tempest/api/object_storage/test_account_services.py
@@ -19,6 +19,7 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
+from tempest.test import HTTP_SUCCESS
class AccountTest(base.BaseObjectTest):
@@ -47,7 +48,7 @@
def test_list_account_metadata(self):
# list all account metadata
resp, metadata = self.account_client.list_account_metadata()
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertIn('x-account-object-count', resp)
self.assertIn('x-account-container-count', resp)
self.assertIn('x-account-bytes-used', resp)
@@ -59,7 +60,7 @@
# add metadata to account
resp, _ = self.account_client.create_account_metadata(
metadata={header: data})
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
resp, _ = self.account_client.list_account_metadata()
self.assertIn('x-account-meta-' + header, resp)
@@ -68,7 +69,7 @@
# delete metadata from account
resp, _ = \
self.account_client.delete_account_metadata(metadata=[header])
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
resp, _ = self.account_client.list_account_metadata()
self.assertNotIn('x-account-meta-' + header, resp)
diff --git a/tempest/api/object_storage/test_container_services.py b/tempest/api/object_storage/test_container_services.py
index 70f704f..5cb6341 100644
--- a/tempest/api/object_storage/test_container_services.py
+++ b/tempest/api/object_storage/test_container_services.py
@@ -19,6 +19,7 @@
from tempest.common.utils.data_utils import arbitrary_string
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
+from tempest.test import HTTP_SUCCESS
class ContainerTest(base.BaseObjectTest):
@@ -46,7 +47,7 @@
self.containers.append(container_name)
# delete container
resp, _ = self.container_client.delete_container(container_name)
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.containers.remove(container_name)
@attr(type='smoke')
@@ -74,7 +75,7 @@
resp, object_list = \
self.container_client.\
list_container_contents(container_name, params=params)
- self.assertEqual(resp['status'], '200')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertIsNotNone(object_list)
object_names = [obj['name'] for obj in object_list]
@@ -95,12 +96,12 @@
resp, _ = \
self.container_client.update_container_metadata(container_name,
metadata=metadata)
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
# list container metadata
resp, _ = self.container_client.list_container_metadata(
container_name)
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertIn('x-container-meta-name', resp)
self.assertIn('x-container-meta-description', resp)
self.assertEqual(resp['x-container-meta-name'], 'Pictures')
@@ -110,10 +111,10 @@
resp, _ = self.container_client.delete_container_metadata(
container_name,
metadata=metadata.keys())
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
# check if the metadata are no longer there
resp, _ = self.container_client.list_container_metadata(container_name)
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertNotIn('x-container-meta-name', resp)
self.assertNotIn('x-container-meta-description', resp)
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index a83e92c..2f52a65 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -23,6 +23,7 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
+from tempest.test import HTTP_SUCCESS
class ObjectTest(base.BaseObjectTest):
@@ -72,7 +73,7 @@
# delete object
resp, _ = self.object_client.delete_object(self.container_name,
object_name)
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
@attr(type='smoke')
def test_object_metadata(self):
@@ -89,12 +90,12 @@
orig_metadata = {meta_key: meta_value}
resp, _ = self.object_client.update_object_metadata(
self.container_name, object_name, orig_metadata)
- self.assertEqual(resp['status'], '202')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
# get object metadata
resp, resp_metadata = self.object_client.list_object_metadata(
self.container_name, object_name)
- self.assertEqual(resp['status'], '200')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
actual_meta_key = 'x-object-meta-' + meta_key
self.assertTrue(actual_meta_key in resp)
self.assertEqual(resp[actual_meta_key], meta_value)
@@ -111,7 +112,7 @@
# get object
resp, body = self.object_client.get_object(self.container_name,
object_name)
- self.assertEqual(resp['status'], '200')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertEqual(body, data)
@attr(type='smoke')
@@ -209,7 +210,7 @@
resp, _ = self.object_client.update_object_metadata(src_container_name,
object_name,
orig_metadata)
- self.assertEqual(resp['status'], '202')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
try:
# copy object from source container to destination container
resp, _ = self.object_client.copy_object_across_containers(
@@ -309,7 +310,7 @@
metadata = {'Temp-URL-Key': key}
resp, _ = self.account_client.create_account_metadata(
metadata=metadata)
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
flag = True
resp, _ = self.account_client.list_account_metadata()
self.assertIn('x-account-meta-temp-url-key', resp)
@@ -386,7 +387,7 @@
md5 = hashlib.md5(local_data).hexdigest()
headers = {'If-None-Match': md5}
resp, body = self.object_client.get(url, headers=headers)
- self.assertEqual(resp['status'], '200')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
class PublicObjectTest(base.BaseObjectTest):
@@ -408,7 +409,7 @@
cont_headers = {'X-Container-Read': '.r:*,.rlistings'}
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers, metadata_prefix='')
- self.assertEqual(resp_meta['status'], '204')
+ self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
# create object
object_name = rand_name(name='Object')
data = arbitrary_string(size=len(object_name),
@@ -420,7 +421,7 @@
# list container metadata
resp_meta, _ = self.container_client.list_container_metadata(
self.container_name)
- self.assertEqual(resp_meta['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertIn('x-container-read', resp_meta)
self.assertEqual(resp_meta['x-container-read'], '.r:*,.rlistings')
@@ -438,7 +439,7 @@
resp_meta, body = self.container_client.update_container_metadata(
self.container_name, metadata=cont_headers,
metadata_prefix='')
- self.assertEqual(resp_meta['status'], '204')
+ self.assertIn(int(resp_meta['status']), HTTP_SUCCESS)
# create object
object_name = rand_name(name='Object')
data = arbitrary_string(size=len(object_name) * 1,
@@ -450,7 +451,7 @@
# list container metadata
resp, _ = self.container_client.list_container_metadata(
self.container_name)
- self.assertEqual(resp['status'], '204')
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertIn('x-container-read', resp)
self.assertEqual(resp['x-container-read'], '.r:*,.rlistings')
diff --git a/tempest/test.py b/tempest/test.py
index 5f403b3..6be37be 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -27,6 +27,9 @@
LOG = logging.getLogger(__name__)
+# All the successful HTTP status codes from RFC 2616
+HTTP_SUCCESS = (200, 201, 202, 203, 204, 205, 206)
+
def attr(*args, **kwargs):
"""A decorator which applies the nose and testtools attr decorator