@@ -42,7 +42,7 @@ def setUp(self):
4242 namespace = 'test_namespace' )
4343
4444 @mock .patch ('grpc.insecure_channel' )
45- def test_throttle_allowed (self , mock_channel ):
45+ def test_allow_success (self , mock_channel ):
4646 # Mock successful OK response
4747 mock_stub = mock .Mock ()
4848 mock_response = RateLimitResponse (overall_code = RateLimitResponseCode .OK )
@@ -51,13 +51,13 @@ def test_throttle_allowed(self, mock_channel):
5151 # Inject mock stub
5252 self .limiter ._stub = mock_stub
5353
54- throttled = self .limiter .throttle ()
54+ allowed = self .limiter .allow ()
5555
56- self .assertTrue (throttled )
56+ self .assertTrue (allowed )
5757 mock_stub .ShouldRateLimit .assert_called_once ()
5858
5959 @mock .patch ('grpc.insecure_channel' )
60- def test_throttle_over_limit_retries_exceeded (self , mock_channel ):
60+ def test_allow_over_limit_retries_exceeded (self , mock_channel ):
6161 # Mock OVER_LIMIT response
6262 mock_stub = mock .Mock ()
6363 mock_response = RateLimitResponse (
@@ -69,9 +69,9 @@ def test_throttle_over_limit_retries_exceeded(self, mock_channel):
6969
7070 # We mock time.sleep to run fast
7171 with mock .patch ('time.sleep' ):
72- throttled = self .limiter .throttle ()
72+ allowed = self .limiter .allow ()
7373
74- self .assertFalse (throttled )
74+ self .assertFalse (allowed )
7575 # Should be called 1 (initial) + 2 (retries) + 1 (last check > retries
7676 # logic depends on loop)
7777 # Logic: attempt starts at 0.
@@ -83,7 +83,7 @@ def test_throttle_over_limit_retries_exceeded(self, mock_channel):
8383 self .assertEqual (mock_stub .ShouldRateLimit .call_count , 3 )
8484
8585 @mock .patch ('grpc.insecure_channel' )
86- def test_throttle_rpc_error_retry (self , mock_channel ):
86+ def test_allow_rpc_error_retry (self , mock_channel ):
8787 # Mock RpcError then Success
8888 mock_stub = mock .Mock ()
8989 mock_response = RateLimitResponse (overall_code = RateLimitResponseCode .OK )
@@ -95,13 +95,13 @@ def test_throttle_rpc_error_retry(self, mock_channel):
9595 self .limiter ._stub = mock_stub
9696
9797 with mock .patch ('time.sleep' ):
98- throttled = self .limiter .throttle ()
98+ allowed = self .limiter .allow ()
9999
100- self .assertTrue (throttled )
100+ self .assertTrue (allowed )
101101 self .assertEqual (mock_stub .ShouldRateLimit .call_count , 3 )
102102
103103 @mock .patch ('grpc.insecure_channel' )
104- def test_throttle_rpc_error_fail (self , mock_channel ):
104+ def test_allow_rpc_error_fail (self , mock_channel ):
105105 # Mock Persistent RpcError
106106 mock_stub = mock .Mock ()
107107 error = grpc .RpcError ()
@@ -111,7 +111,7 @@ def test_throttle_rpc_error_fail(self, mock_channel):
111111
112112 with mock .patch ('time.sleep' ):
113113 with self .assertRaises (grpc .RpcError ):
114- self .limiter .throttle ()
114+ self .limiter .allow ()
115115
116116 # The inner loop tries 5 times for connection errors
117117 self .assertEqual (mock_stub .ShouldRateLimit .call_count , 5 )
@@ -134,7 +134,7 @@ def test_extract_duration_from_response(self, mock_random, mock_channel):
134134 self .limiter .retries = 0 # Single attempt
135135
136136 with mock .patch ('time.sleep' ) as mock_sleep :
137- self .limiter .throttle ()
137+ self .limiter .allow ()
138138 # Should sleep for 5 seconds (jitter is 0.0)
139139 mock_sleep .assert_called_with (5.0 )
140140
0 commit comments