mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 04:12:02 +00:00
Make RateLimitTests less brittle to speedy tests
(imported from commit 1b81356d90bdb19b0550363aebb2f1426d386d10)
This commit is contained in:
@@ -2895,6 +2895,11 @@ class RateLimitTests(AuthedTestCase):
|
|||||||
def test_headers(self):
|
def test_headers(self):
|
||||||
email = "hamlet@humbughq.com"
|
email = "hamlet@humbughq.com"
|
||||||
api_key = self.get_api_key(email)
|
api_key = self.get_api_key(email)
|
||||||
|
|
||||||
|
# Sleep 1 second and succeed again
|
||||||
|
import time
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
result = self.send_api_message(email, api_key, "some stuff")
|
result = self.send_api_message(email, api_key, "some stuff")
|
||||||
self.assertTrue('X-RateLimit-Remaining' in result)
|
self.assertTrue('X-RateLimit-Remaining' in result)
|
||||||
self.assertTrue('X-RateLimit-Limit' in result)
|
self.assertTrue('X-RateLimit-Limit' in result)
|
||||||
@@ -2921,7 +2926,7 @@ class RateLimitTests(AuthedTestCase):
|
|||||||
self.assertEqual(json.get("result"), "error")
|
self.assertEqual(json.get("result"), "error")
|
||||||
self.assertIn("API usage exceeded rate limit, try again in", json.get("msg"))
|
self.assertIn("API usage exceeded rate limit, try again in", json.get("msg"))
|
||||||
|
|
||||||
# Sleep 5 seconds and succeed again
|
# Sleep 1 second and succeed again
|
||||||
import time
|
import time
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
result = self.send_api_message(email, api_key, "Good message")
|
result = self.send_api_message(email, api_key, "Good message")
|
||||||
|
|||||||
Reference in New Issue
Block a user