File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -279,17 +279,27 @@ def test_unknown_error(self):
279
279
self .run_client (self .client .country (ip ))
280
280
281
281
def test_request (self ):
282
- matcher = HeaderValueMatcher (
283
- {
284
- "Accept" : "application/json" ,
285
- "Authorization" : "Basic NDI6YWJjZGVmMTIzNDU2" ,
286
- "User-Agent" : lambda x : x .startswith ("GeoIP2-Python-Client/" ),
287
- }
288
- )
282
+ def user_agent_compare (actual : str , expected : str ) -> bool :
283
+ if actual is None :
284
+ return False
285
+ return actual .startswith ("GeoIP2-Python-Client/" )
286
+
287
+ def accept_compare (actual : str , expected : str ) -> bool :
288
+ return actual == "application/json"
289
+
290
+ def authorization_compare (actual : str , expected : str ) -> bool :
291
+ return actual == "Basic NDI6YWJjZGVmMTIzNDU2"
292
+
289
293
self .httpserver .expect_request (
290
294
"/geoip/v2.1/country/1.2.3.4" ,
291
295
method = "GET" ,
292
- header_value_matcher = matcher ,
296
+ header_value_matcher = HeaderValueMatcher (
297
+ {
298
+ "User-Agent" : user_agent_compare ,
299
+ "Accept" : accept_compare ,
300
+ "Authorization" : authorization_compare ,
301
+ }
302
+ ),
293
303
).respond_with_json (
294
304
self .country ,
295
305
status = 200 ,
You can’t perform that action at this time.
0 commit comments