summaryrefslogtreecommitdiff
path: root/trove/tests/unittests/api/common
diff options
context:
space:
mode:
authordaniel-a-nguyen <daniel.a.nguyen@hp.com>2014-03-19 08:30:47 -0700
committerdaniel-a-nguyen <dan.nguyens.mail@gmail.com>2014-04-17 16:00:46 -0700
commitd07c8c0445dca42ef5a27bbf945b9f99a4995aab (patch)
tree5e81476f67a0e783a741d9f52ba8790c8e0402f7 /trove/tests/unittests/api/common
parent7f20bfa08dc1e6d54fe7073bcc259d574c0a261f (diff)
downloadtrove-d07c8c0445dca42ef5a27bbf945b9f99a4995aab.tar.gz
Added separate rate limit setting for mgmt POST
Created a simple unittest Fixed typo granced --> granted Fixed test to show that the 4th request will result in a delay Change-Id: I95062a805aaae88432c081d5f1d0a2da81d7108c Closes-Bug: #1294421
Diffstat (limited to 'trove/tests/unittests/api/common')
-rw-r--r--trove/tests/unittests/api/common/test_limits.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/trove/tests/unittests/api/common/test_limits.py b/trove/tests/unittests/api/common/test_limits.py
index e74e3c2f..f217fef0 100644
--- a/trove/tests/unittests/api/common/test_limits.py
+++ b/trove/tests/unittests/api/common/test_limits.py
@@ -34,6 +34,7 @@ from trove.quota.quota import QUOTAS
TEST_LIMITS = [
Limit("GET", "/delayed", "^/delayed", 1, limits.PER_MINUTE),
Limit("POST", "*", ".*", 7, limits.PER_MINUTE),
+ Limit("POST", "/mgmt", "^/mgmt", 3, limits.PER_MINUTE),
Limit("PUT", "*", "", 10, limits.PER_MINUTE),
]
@@ -378,7 +379,7 @@ class LimiterTest(BaseLimitTestSuite):
def test_delay_PUT(self):
"""
Ensure the 11th PUT will result in a delay of 6.0 seconds until
- the next request will be granced.
+ the next request will be granted.
"""
expected = [None] * 10 + [6.0]
results = list(self._check(11, "PUT", "/anything"))
@@ -388,7 +389,7 @@ class LimiterTest(BaseLimitTestSuite):
def test_delay_POST(self):
"""
Ensure the 8th POST will result in a delay of 6.0 seconds until
- the next request will be granced.
+ the next request will be granted.
"""
expected = [None] * 7
results = list(self._check(7, "POST", "/anything"))
@@ -398,10 +399,23 @@ class LimiterTest(BaseLimitTestSuite):
results = self._check_sum(1, "POST", "/anything")
self.assertAlmostEqual(expected, results, 8)
+ def test_delay_POST_mgmt(self):
+ """
+ Ensure the 4th mgmt POST will result in a delay of 6.0 seconds until
+ the next request will be granted.
+ """
+ expected = [None] * 3
+ results = list(self._check(3, "POST", "/mgmt"))
+ self.assertEqual(expected, results)
+
+ expected = 60.0 / 3.0
+ results = self._check_sum(1, "POST", "/mgmt")
+ self.assertAlmostEqual(expected, results, 4)
+
def test_delay_GET(self):
# Ensure the 11th GET will result in NO delay.
expected = [None] * 11
- results = list(self._check(11, "GET", "/anything"))
+ results = list(self._check(11, "GET", "/mgmt"))
self.assertEqual(expected, results)