@@ -539,28 +539,30 @@ class Model(BaseModel):
539
539
"remaining_retries,retry_after,timeout" ,
540
540
[
541
541
[3 , "20" , 20 ],
542
- [3 , "0" , 2 ],
543
- [3 , "-10" , 2 ],
542
+ [3 , "0" , 0.5 ],
543
+ [3 , "-10" , 0.5 ],
544
544
[3 , "60" , 60 ],
545
- [3 , "61" , 2 ],
545
+ [3 , "61" , 0.5 ],
546
546
[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 ],
549
549
[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 ],
554
556
],
555
557
)
556
558
@mock .patch ("time.time" , mock .MagicMock (return_value = 1696004797 ))
557
559
def test_parse_retry_after_header (self , remaining_retries : int , retry_after : str , timeout : float ) -> None :
558
560
client = Orb (base_url = base_url , api_key = api_key , _strict_response_validation = True )
559
561
560
562
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 )
562
564
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]
564
566
565
567
566
568
class TestAsyncOrb :
@@ -1083,18 +1085,20 @@ class Model(BaseModel):
1083
1085
"remaining_retries,retry_after,timeout" ,
1084
1086
[
1085
1087
[3 , "20" , 20 ],
1086
- [3 , "0" , 2 ],
1087
- [3 , "-10" , 2 ],
1088
+ [3 , "0" , 0.5 ],
1089
+ [3 , "-10" , 0.5 ],
1088
1090
[3 , "60" , 60 ],
1089
- [3 , "61" , 2 ],
1091
+ [3 , "61" , 0.5 ],
1090
1092
[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 ],
1093
1095
[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 ],
1098
1102
],
1099
1103
)
1100
1104
@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
1103
1107
client = AsyncOrb (base_url = base_url , api_key = api_key , _strict_response_validation = True )
1104
1108
1105
1109
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 )
1107
1111
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