summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>2015-01-19 04:46:39 +0000
committerKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>2015-01-20 05:09:09 +0000
commit9018af62c46e1cecb955ebe29960c98c548b63f8 (patch)
tree4f84688ec53a51df8d0e91b8e50d64ba2ecdd61c
parent84dee6b7818c2c755b8338c527b0059f74f9f07a (diff)
downloadtempest-lib-9018af62c46e1cecb955ebe29960c98c548b63f8.tar.gz
Add RateLimitExceeded test case
The rest_client module raises RateLimitExceeded exception, but there was not any tests for the exception. This patch adds it. Change-Id: I933ebe2ed52750088e3941b308b669f088d7f8ed
-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):