1919def test_client_defaults () -> None :
2020 client = TwexApiClient ("secret-key" )
2121 assert client .base_url == DEFAULT_BASE_URL
22- assert f"x-api-scraper-haystack/{ __version__ } " == USER_AGENT
22+ assert USER_AGENT == f"x-api-scraper-haystack/{ __version__ } "
2323 assert client .headers ["Authorization" ] == "Bearer secret-key"
2424
2525
2626@pytest .mark .parametrize (
2727 ("api_key" , "kwargs" , "error" ),
2828 [
2929 (" " , {}, "api_key is empty" ),
30- (
31- "secret-key" ,
32- {"timeout_seconds" : 0 },
33- "timeout_seconds must be greater than 0" ,
34- ),
30+ ("secret-key" , {"timeout_seconds" : 0 }, "timeout_seconds must be greater than 0" ),
3531 (
3632 "secret-key" ,
3733 {"base_url" : "twexapi.test" },
@@ -115,9 +111,7 @@ def handler(request: httpx.Request) -> httpx.Response:
115111def test_http_and_json_errors () -> None :
116112 with httpx .Client (
117113 base_url = "https://api.twexapi.test" ,
118- transport = httpx .MockTransport (
119- lambda request : httpx .Response (401 , text = "denied" )
120- ),
114+ transport = httpx .MockTransport (lambda request : httpx .Response (401 , text = "denied" )),
121115 ) as http_client :
122116 client = TwexApiClient ("secret-key" , http_client = http_client )
123117 with pytest .raises (TwexApiError , match = "HTTP 401" ) as exc :
@@ -137,9 +131,7 @@ def test_http_and_json_errors() -> None:
137131
138132 with httpx .Client (
139133 base_url = "https://api.twexapi.test" ,
140- transport = httpx .MockTransport (
141- lambda request : httpx .Response (200 , json = ["nope" ])
142- ),
134+ transport = httpx .MockTransport (lambda request : httpx .Response (200 , json = ["nope" ])),
143135 ) as http_client :
144136 client = TwexApiClient ("secret-key" , http_client = http_client )
145137 with pytest .raises (TwexApiError , match = "unexpected JSON" ):
0 commit comments