Added missing ratelimit tests. Pretty sure I already did this?
@@ -592,7 +592,7 @@ class TestRESTBucketManager:
route = mock.MagicMock()
route.create_real_bucket_hash = mock.MagicMock(return_value="eat pant;bobs")
bucket = mock.MagicMock()
- mgr.routes_to_hashes[route] = "eat pant"
+ mgr.routes_to_hashes[route.route_template] = "eat pant"
mgr.real_hashes_to_buckets["eat pant;bobs"] = bucket
f = mgr.acquire(route)
@@ -613,11 +613,11 @@ class TestRESTBucketManager:
with ratelimits.RESTBucketManager() as mgr:
route = mock.MagicMock()
route.create_real_bucket_hash = mock.MagicMock(wraps=lambda intial_hash: intial_hash + ";bobs")
- mgr.routes_to_hashes[route] = "123"
+ mgr.routes_to_hashes[route.route_template] = "123"
bucket = mock.MagicMock()
mgr.real_hashes_to_buckets["123;bobs"] = bucket
mgr.update_rate_limits(route, "123", 22, 23, datetime.datetime.now(), datetime.datetime.now())
- assert mgr.routes_to_hashes[route] == "123"
+ assert mgr.routes_to_hashes[route.route_template] == "123"
assert mgr.real_hashes_to_buckets["123;bobs"] is bucket
@pytest.mark.asyncio
@@ -625,7 +625,7 @@ class TestRESTBucketManager:
with ratelimits.RESTBucketManager() as mgr:
route = mock.MagicMock()
route.create_real_bucket_hash = mock.MagicMock(wraps=lambda intial_hash: intial_hash + ";bobs")
- mgr.routes_to_hashes[route] = "123"
+ mgr.routes_to_hashes[route.route_template] = "123"
bucket = mock.MagicMock()
mgr.real_hashes_to_buckets["123;bobs"] = bucket
date = datetime.datetime.now().replace(year=2004)
@@ -636,6 +636,12 @@ class TestRESTBucketManager:
mgr.update_rate_limits(route, "123", 22, 23, date, reset_at)
bucket.update_rate_limit.assert_called_once_with(22, 23, expect_reset_at_monotonic)
+ @pytest.mark.parametrize(("gc_task", "is_started"), [(None, False), (object(), True)])
+ def test_is_started(self, gc_task, is_started):
+ with ratelimits.RESTBucketManager() as mgr:
+ mgr.gc_task = gc_task
+ assert mgr.is_started is is_started
+
class TestExponentialBackOff:
def test_reset(self):
