diff options
author | John Dickinson <me@not.mn> | 2013-12-23 13:49:46 -0800 |
---|---|---|
committer | John Dickinson <me@not.mn> | 2013-12-23 13:53:18 -0800 |
commit | 5187fd313f3387644504e027f5191aa60475cbc2 (patch) | |
tree | a98aabfedbd71df06b49588a335b2c0c751cecef /tests/test_swiftclient.py | |
parent | 3580bd90d09568ffb2ffeb56f6160684171001e0 (diff) | |
download | python-swiftclient-5187fd313f3387644504e027f5191aa60475cbc2.tar.gz |
retry on ratelimit
Added a retry_on_ratelimit parameter to the Connection
class so that ratelimited requests can be retried.
DocImpact
Change-Id: I2817a7ea0ed2d69a7659e80111fbd2c91a75d530
Diffstat (limited to 'tests/test_swiftclient.py')
-rw-r--r-- | tests/test_swiftclient.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py index 390a40e..6c680d6 100644 --- a/tests/test_swiftclient.py +++ b/tests/test_swiftclient.py @@ -713,6 +713,24 @@ class TestConnection(MockHttpTest): self.assertRaises(c.ClientException, conn.head_account) self.assertEqual(conn.attempts, conn.retries + 1) + def test_retry_on_ratelimit(self): + c.http_connection = self.fake_http_connection(498) + + def quick_sleep(*args): + pass + c.sleep = quick_sleep + + # test retries + conn = c.Connection('http://www.test.com', 'asdf', 'asdf', + retry_on_ratelimit=True) + self.assertRaises(c.ClientException, conn.head_account) + self.assertEqual(conn.attempts, conn.retries + 1) + + # test default no-retry + conn = c.Connection('http://www.test.com', 'asdf', 'asdf') + self.assertRaises(c.ClientException, conn.head_account) + self.assertEqual(conn.attempts, 1) + def test_resp_read_on_server_error(self): c.http_connection = self.fake_http_connection(500) conn = c.Connection('http://www.test.com', 'asdf', 'asdf', retries=0) |