@@ -55,7 +55,7 @@ def json(self):
55
55
elif kwargs ['url' ] == 'http://127.0.0.1:400/token' :
56
56
return MockResponse ({"reason" : "test_reason" , "json_data" : {"error" :"unrecoverable" , "error_description" :"nah" }}, 400 )
57
57
elif kwargs ['url' ] == 'http://127.0.0.1:429/token' :
58
- return MockResponse ({"reason" : "test_reason" , "headers" : {"X-RateLimit-Reset" : time . time () * 1000 + 2000 }}, 429 )
58
+ return MockResponse ({"reason" : "test_reason" , "headers" : {"X-RateLimit-Reset" : 234 }}, 429 )
59
59
elif kwargs ['url' ] == 'http://127.0.0.1:500/token' :
60
60
return MockResponse ({"reason" : "test_reason" , "json_data" : {"error" :"recoverable" , "error_description" :"nah" }}, 500 )
61
61
elif kwargs ['url' ] == 'http://127.0.0.1:501/token' :
@@ -106,7 +106,7 @@ def test_oauth_fail_with_retries(self, mock_post):
106
106
def test_oauth_rate_limit_delay (self , mock_sleep , mock_post ):
107
107
manager = segment .analytics .oauth_manager .OauthManager ("id" , privatekey , "keyid" , "http://127.0.0.1:429" )
108
108
manager ._poller_loop ()
109
- self . assertTrue ( mock_sleep .call_args [ 0 ][ 0 ] > 1.9 and mock_sleep . call_args [ 0 ][ 0 ] <= 2.0 )
109
+ mock_sleep .assert_called_with ( 234 )
110
110
111
111
class TestOauthIntegration (unittest .TestCase ):
112
112
def fail (self , e , batch = []):
@@ -152,4 +152,4 @@ def test_oauth_integration_fail_bad_key(self, mock_post):
152
152
self .assertTrue (self .failed )
153
153
154
154
if __name__ == '__main__' :
155
- unittest .main ()
155
+ unittest .main ()
0 commit comments