@@ -639,28 +639,30 @@ class Model(BaseModel):
639
639
"remaining_retries,retry_after,timeout" ,
640
640
[
641
641
[3 , "20" , 20 ],
642
- [3 , "0" , 2 ],
643
- [3 , "-10" , 2 ],
642
+ [3 , "0" , 0.5 ],
643
+ [3 , "-10" , 0.5 ],
644
644
[3 , "60" , 60 ],
645
- [3 , "61" , 2 ],
645
+ [3 , "61" , 0.5 ],
646
646
[3 , "Fri, 29 Sep 2023 16:26:57 GMT" , 20 ],
647
- [3 , "Fri, 29 Sep 2023 16:26:37 GMT" , 2 ],
648
- [3 , "Fri, 29 Sep 2023 16:26:27 GMT" , 2 ],
647
+ [3 , "Fri, 29 Sep 2023 16:26:37 GMT" , 0.5 ],
648
+ [3 , "Fri, 29 Sep 2023 16:26:27 GMT" , 0.5 ],
649
649
[3 , "Fri, 29 Sep 2023 16:27:37 GMT" , 60 ],
650
- [3 , "Fri, 29 Sep 2023 16:27:38 GMT" , 2 ],
651
- [3 , "99999999999999999999999999999999999" , 2 ],
652
- [3 , "Zun, 29 Sep 2023 16:26:27 GMT" , 2 ],
653
- [3 , "" , 2 ],
650
+ [3 , "Fri, 29 Sep 2023 16:27:38 GMT" , 0.5 ],
651
+ [3 , "99999999999999999999999999999999999" , 0.5 ],
652
+ [3 , "Zun, 29 Sep 2023 16:26:27 GMT" , 0.5 ],
653
+ [3 , "" , 0.5 ],
654
+ [2 , "" , 0.5 * 2.0 ],
655
+ [1 , "" , 0.5 * 4.0 ],
654
656
],
655
657
)
656
658
@mock .patch ("time.time" , mock .MagicMock (return_value = 1696004797 ))
657
659
def test_parse_retry_after_header (self , remaining_retries : int , retry_after : str , timeout : float ) -> None :
658
660
client = Finch (base_url = base_url , access_token = access_token , _strict_response_validation = True )
659
661
660
662
headers = httpx .Headers ({"retry-after" : retry_after })
661
- options = FinalRequestOptions (method = "get" , url = "/foo" , max_retries = 2 )
663
+ options = FinalRequestOptions (method = "get" , url = "/foo" , max_retries = 3 )
662
664
calculated = client ._calculate_retry_timeout (remaining_retries , options , headers )
663
- assert calculated == pytest .approx (timeout , 0.6 ) # pyright: ignore[reportUnknownMemberType]
665
+ assert calculated == pytest .approx (timeout , 0.5 * 0.875 ) # pyright: ignore[reportUnknownMemberType]
664
666
665
667
666
668
class TestAsyncFinch :
@@ -1272,18 +1274,20 @@ class Model(BaseModel):
1272
1274
"remaining_retries,retry_after,timeout" ,
1273
1275
[
1274
1276
[3 , "20" , 20 ],
1275
- [3 , "0" , 2 ],
1276
- [3 , "-10" , 2 ],
1277
+ [3 , "0" , 0.5 ],
1278
+ [3 , "-10" , 0.5 ],
1277
1279
[3 , "60" , 60 ],
1278
- [3 , "61" , 2 ],
1280
+ [3 , "61" , 0.5 ],
1279
1281
[3 , "Fri, 29 Sep 2023 16:26:57 GMT" , 20 ],
1280
- [3 , "Fri, 29 Sep 2023 16:26:37 GMT" , 2 ],
1281
- [3 , "Fri, 29 Sep 2023 16:26:27 GMT" , 2 ],
1282
+ [3 , "Fri, 29 Sep 2023 16:26:37 GMT" , 0.5 ],
1283
+ [3 , "Fri, 29 Sep 2023 16:26:27 GMT" , 0.5 ],
1282
1284
[3 , "Fri, 29 Sep 2023 16:27:37 GMT" , 60 ],
1283
- [3 , "Fri, 29 Sep 2023 16:27:38 GMT" , 2 ],
1284
- [3 , "99999999999999999999999999999999999" , 2 ],
1285
- [3 , "Zun, 29 Sep 2023 16:26:27 GMT" , 2 ],
1286
- [3 , "" , 2 ],
1285
+ [3 , "Fri, 29 Sep 2023 16:27:38 GMT" , 0.5 ],
1286
+ [3 , "99999999999999999999999999999999999" , 0.5 ],
1287
+ [3 , "Zun, 29 Sep 2023 16:26:27 GMT" , 0.5 ],
1288
+ [3 , "" , 0.5 ],
1289
+ [2 , "" , 0.5 * 2.0 ],
1290
+ [1 , "" , 0.5 * 4.0 ],
1287
1291
],
1288
1292
)
1289
1293
@mock .patch ("time.time" , mock .MagicMock (return_value = 1696004797 ))
@@ -1292,6 +1296,6 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte
1292
1296
client = AsyncFinch (base_url = base_url , access_token = access_token , _strict_response_validation = True )
1293
1297
1294
1298
headers = httpx .Headers ({"retry-after" : retry_after })
1295
- options = FinalRequestOptions (method = "get" , url = "/foo" , max_retries = 2 )
1299
+ options = FinalRequestOptions (method = "get" , url = "/foo" , max_retries = 3 )
1296
1300
calculated = client ._calculate_retry_timeout (remaining_retries , options , headers )
1297
- assert calculated == pytest .approx (timeout , 0.6 ) # pyright: ignore[reportUnknownMemberType]
1301
+ assert calculated == pytest .approx (timeout , 0.5 * 0.875 ) # pyright: ignore[reportUnknownMemberType]
0 commit comments