@@ -539,28 +539,30 @@ class Model(BaseModel):
539539 "remaining_retries,retry_after,timeout" ,
540540 [
541541 [3 , "20" , 20 ],
542- [3 , "0" , 2 ],
543- [3 , "-10" , 2 ],
542+ [3 , "0" , 0.5 ],
543+ [3 , "-10" , 0.5 ],
544544 [3 , "60" , 60 ],
545- [3 , "61" , 2 ],
545+ [3 , "61" , 0.5 ],
546546 [3 , "Fri, 29 Sep 2023 16:26:57 GMT" , 20 ],
547- [3 , "Fri, 29 Sep 2023 16:26:37 GMT" , 2 ],
548- [3 , "Fri, 29 Sep 2023 16:26:27 GMT" , 2 ],
547+ [3 , "Fri, 29 Sep 2023 16:26:37 GMT" , 0.5 ],
548+ [3 , "Fri, 29 Sep 2023 16:26:27 GMT" , 0.5 ],
549549 [3 , "Fri, 29 Sep 2023 16:27:37 GMT" , 60 ],
550- [3 , "Fri, 29 Sep 2023 16:27:38 GMT" , 2 ],
551- [3 , "99999999999999999999999999999999999" , 2 ],
552- [3 , "Zun, 29 Sep 2023 16:26:27 GMT" , 2 ],
553- [3 , "" , 2 ],
550+ [3 , "Fri, 29 Sep 2023 16:27:38 GMT" , 0.5 ],
551+ [3 , "99999999999999999999999999999999999" , 0.5 ],
552+ [3 , "Zun, 29 Sep 2023 16:26:27 GMT" , 0.5 ],
553+ [3 , "" , 0.5 ],
554+ [2 , "" , 0.5 * 2.0 ],
555+ [1 , "" , 0.5 * 4.0 ],
554556 ],
555557 )
556558 @mock .patch ("time.time" , mock .MagicMock (return_value = 1696004797 ))
557559 def test_parse_retry_after_header (self , remaining_retries : int , retry_after : str , timeout : float ) -> None :
558560 client = Orb (base_url = base_url , api_key = api_key , _strict_response_validation = True )
559561
560562 headers = httpx .Headers ({"retry-after" : retry_after })
561- options = FinalRequestOptions (method = "get" , url = "/foo" , max_retries = 2 )
563+ options = FinalRequestOptions (method = "get" , url = "/foo" , max_retries = 3 )
562564 calculated = client ._calculate_retry_timeout (remaining_retries , options , headers )
563- assert calculated == pytest .approx (timeout , 0.6 ) # pyright: ignore[reportUnknownMemberType]
565+ assert calculated == pytest .approx (timeout , 0.5 * 0.875 ) # pyright: ignore[reportUnknownMemberType]
564566
565567
566568class TestAsyncOrb :
@@ -1083,18 +1085,20 @@ class Model(BaseModel):
10831085 "remaining_retries,retry_after,timeout" ,
10841086 [
10851087 [3 , "20" , 20 ],
1086- [3 , "0" , 2 ],
1087- [3 , "-10" , 2 ],
1088+ [3 , "0" , 0.5 ],
1089+ [3 , "-10" , 0.5 ],
10881090 [3 , "60" , 60 ],
1089- [3 , "61" , 2 ],
1091+ [3 , "61" , 0.5 ],
10901092 [3 , "Fri, 29 Sep 2023 16:26:57 GMT" , 20 ],
1091- [3 , "Fri, 29 Sep 2023 16:26:37 GMT" , 2 ],
1092- [3 , "Fri, 29 Sep 2023 16:26:27 GMT" , 2 ],
1093+ [3 , "Fri, 29 Sep 2023 16:26:37 GMT" , 0.5 ],
1094+ [3 , "Fri, 29 Sep 2023 16:26:27 GMT" , 0.5 ],
10931095 [3 , "Fri, 29 Sep 2023 16:27:37 GMT" , 60 ],
1094- [3 , "Fri, 29 Sep 2023 16:27:38 GMT" , 2 ],
1095- [3 , "99999999999999999999999999999999999" , 2 ],
1096- [3 , "Zun, 29 Sep 2023 16:26:27 GMT" , 2 ],
1097- [3 , "" , 2 ],
1096+ [3 , "Fri, 29 Sep 2023 16:27:38 GMT" , 0.5 ],
1097+ [3 , "99999999999999999999999999999999999" , 0.5 ],
1098+ [3 , "Zun, 29 Sep 2023 16:26:27 GMT" , 0.5 ],
1099+ [3 , "" , 0.5 ],
1100+ [2 , "" , 0.5 * 2.0 ],
1101+ [1 , "" , 0.5 * 4.0 ],
10981102 ],
10991103 )
11001104 @mock .patch ("time.time" , mock .MagicMock (return_value = 1696004797 ))
@@ -1103,6 +1107,6 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte
11031107 client = AsyncOrb (base_url = base_url , api_key = api_key , _strict_response_validation = True )
11041108
11051109 headers = httpx .Headers ({"retry-after" : retry_after })
1106- options = FinalRequestOptions (method = "get" , url = "/foo" , max_retries = 2 )
1110+ options = FinalRequestOptions (method = "get" , url = "/foo" , max_retries = 3 )
11071111 calculated = client ._calculate_retry_timeout (remaining_retries , options , headers )
1108- assert calculated == pytest .approx (timeout , 0.6 ) # pyright: ignore[reportUnknownMemberType]
1112+ assert calculated == pytest .approx (timeout , 0.5 * 0.875 ) # pyright: ignore[reportUnknownMemberType]
0 commit comments