@@ -1855,13 +1855,33 @@ def dummy_ping(*args, **kwargs):
18551855 await shark .shutdown ()
18561856
18571857 @pytest .mark .asyncio
1858- async def test_rate_limit (self ):
1858+ @pytest .mark .parametrize (
1859+ 'response_header_name, config_header_names, config_header_name' ,
1860+ (
1861+ (
1862+ 'X-Rate-Limit-Reset' ,
1863+ ['X-Rate-Limit-Reset' , 'Retry-After' ],
1864+ None ,
1865+ ),
1866+ ('Retry-After' , ['X-Rate-Limit-Reset' , 'Retry-After' ], None ),
1867+ ('X-Rate-Limit-Reset' , [], 'X-Rate-Limit-Reset' ),
1868+ ),
1869+ )
1870+ async def test_rate_limit (
1871+ self , response_header_name , config_header_names , config_header_name
1872+ ):
18591873 """
18601874 Make sure SocketShark retries 429 responses appropriately.
18611875 """
18621876 http_retry_config = TEST_CONFIG .copy ()
18631877 http_retry_config ['HTTP' ]['tries' ] = 2
18641878 http_retry_config ['HTTP' ]['wait' ] = 1
1879+ http_retry_config ['HTTP' ][
1880+ 'rate_limit_reset_header_names'
1881+ ] = config_header_names
1882+ http_retry_config ['HTTP' ][
1883+ 'rate_limit_reset_header_name'
1884+ ] = config_header_name
18651885 shark = SocketShark (http_retry_config )
18661886 await shark .prepare ()
18671887 client = MockClient (shark )
@@ -1876,7 +1896,7 @@ async def test_rate_limit(self):
18761896 conf ['before_subscribe' ],
18771897 status = 429 ,
18781898 headers = {
1879- 'X-Rate-Limit-Reset' : '0.2' ,
1899+ response_header_name : '0.2' ,
18801900 },
18811901 )
18821902 mock .post (
0 commit comments