summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-01-21 23:16:51 +0000
committerGerrit Code Review <review@openstack.org>2015-01-21 23:16:51 +0000
commit38f3fc06ce8b508d2e0aa2acf17463e5dc2f0fb8 (patch)
treeaa4808a5f2497e8d8f7881e00fb2c39ca34c8c06
parentefb491bded68617f6361f2fc432f881c4e1ff93b (diff)
parent9018af62c46e1cecb955ebe29960c98c548b63f8 (diff)
downloadtempest-lib-38f3fc06ce8b508d2e0aa2acf17463e5dc2f0fb8.tar.gz
Merge "Add RateLimitExceeded test case"
-rw-r--r--tempest_lib/tests/test_rest_client.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/tempest_lib/tests/test_rest_client.py b/tempest_lib/tests/test_rest_client.py
index 5721b18..dc819d0 100644
--- a/tempest_lib/tests/test_rest_client.py
+++ b/tempest_lib/tests/test_rest_client.py
@@ -274,10 +274,15 @@ class TestRestClientParseRespJSON(BaseRestClientTestClass):
class TestRestClientErrorCheckerJSON(base.TestCase):
c_type = "application/json"
- def set_data(self, r_code, enc=None, r_body=None):
+ def set_data(self, r_code, enc=None, r_body=None, absolute_limit=True):
if enc is None:
enc = self.c_type
resp_dict = {'status': r_code, 'content-type': enc}
+ resp_body = {'resp_body': 'fake_resp_body'}
+
+ if absolute_limit is False:
+ resp_dict.update({'retry-after': 120})
+ resp_body.update({'overLimit': {'message': 'fake_message'}})
resp = httplib2.Response(resp_dict)
data = {
"method": "fake_method",
@@ -285,7 +290,7 @@ class TestRestClientErrorCheckerJSON(base.TestCase):
"headers": "fake_headers",
"body": "fake_body",
"resp": resp,
- "resp_body": '{"resp_body": "fake_resp_body"}',
+ "resp_body": json.dumps(resp_body)
}
if r_body is not None:
data.update({"resp_body": r_body})
@@ -329,6 +334,11 @@ class TestRestClientErrorCheckerJSON(base.TestCase):
self.rest_client._error_checker,
**self.set_data("413"))
+ def test_response_413_without_absolute_limit(self):
+ self.assertRaises(exceptions.RateLimitExceeded,
+ self.rest_client._error_checker,
+ **self.set_data("413", absolute_limit=False))
+
def test_response_415(self):
self.assertRaises(exceptions.InvalidContentType,
self.rest_client._error_checker,
@@ -381,6 +391,11 @@ class TestRestClientErrorCheckerTEXT(TestRestClientErrorCheckerJSON):
self.rest_client._error_checker,
**self.set_data("405", enc="fake_enc"))
+ def test_response_413_without_absolute_limit(self):
+ # Skip this test because rest_client cannot get overLimit message
+ # from text body.
+ pass
+
class TestRestClientUtils(BaseRestClientTestClass):