@@ -66,7 +66,9 @@ def setup_httpserver(self, httpserver: pytest_httpserver.HTTPServer):
6666 self .httpserver = httpserver
6767
6868 def test_country_ok (self ):
69- self .httpserver .expect_request ("/geoip/v2.1/country/1.2.3.4" ).respond_with_json (
69+ self .httpserver .expect_request (
70+ "/geoip/v2.1/country/1.2.3.4" , method = "GET"
71+ ).respond_with_json (
7072 self .country ,
7173 status = 200 ,
7274 content_type = self ._content_type ("country" ),
@@ -110,7 +112,9 @@ def test_country_ok(self):
110112 self .assertEqual (country .raw , self .country , "raw response is correct" )
111113
112114 def test_me (self ):
113- self .httpserver .expect_request ("/geoip/v2.1/country/me" ).respond_with_json (
115+ self .httpserver .expect_request (
116+ "/geoip/v2.1/country/me" , method = "GET"
117+ ).respond_with_json (
114118 self .country ,
115119 status = 200 ,
116120 content_type = self ._content_type ("country" ),
@@ -127,7 +131,9 @@ def test_me(self):
127131 )
128132
129133 def test_200_error (self ):
130- self .httpserver .expect_request ("/geoip/v2.1/country/1.1.1.1" ).respond_with_data (
134+ self .httpserver .expect_request (
135+ "/geoip/v2.1/country/1.1.1.1" , method = "GET"
136+ ).respond_with_data (
131137 "" ,
132138 status = 200 ,
133139 content_type = self ._content_type ("country" ),
@@ -146,7 +152,7 @@ def test_bad_ip_address(self):
146152
147153 def test_no_body_error (self ):
148154 self .httpserver .expect_request (
149- "/geoip/v2.1/country/1.2.3.7"
155+ "/geoip/v2.1/country/1.2.3.7" , method = "GET"
150156 ).respond_with_data (
151157 "" ,
152158 status = 400 ,
@@ -160,7 +166,7 @@ def test_no_body_error(self):
160166 def test_weird_body_error (self ):
161167
162168 self .httpserver .expect_request (
163- "/geoip/v2.1/country/1.2.3.8"
169+ "/geoip/v2.1/country/1.2.3.8" , method = "GET"
164170 ).respond_with_json (
165171 {"wierd" : 42 },
166172 status = 400 ,
@@ -176,7 +182,7 @@ def test_weird_body_error(self):
176182 def test_bad_body_error (self ):
177183
178184 self .httpserver .expect_request (
179- "/geoip/v2.1/country/1.2.3.9"
185+ "/geoip/v2.1/country/1.2.3.9" , method = "GET"
180186 ).respond_with_data (
181187 "bad body" ,
182188 status = 400 ,
@@ -189,7 +195,7 @@ def test_bad_body_error(self):
189195
190196 def test_500_error (self ):
191197 self .httpserver .expect_request (
192- "/geoip/v2.1/country/1.2.3.10"
198+ "/geoip/v2.1/country/1.2.3.10" , method = "GET"
193199 ).respond_with_data (
194200 "" ,
195201 status = 500 ,
@@ -201,7 +207,7 @@ def test_500_error(self):
201207 def test_300_error (self ):
202208
203209 self .httpserver .expect_request (
204- "/geoip/v2.1/country/1.2.3.11"
210+ "/geoip/v2.1/country/1.2.3.11" , method = "GET"
205211 ).respond_with_data (
206212 "" ,
207213 status = 300 ,
@@ -249,7 +255,7 @@ def _test_error(self, status, error_code, error_class):
249255 msg = "Some error message"
250256 body = {"error" : msg , "code" : error_code }
251257 self .httpserver .expect_request (
252- "/geoip/v2.1/country/1.2.3.18"
258+ "/geoip/v2.1/country/1.2.3.18" , method = "GET"
253259 ).respond_with_json (
254260 body ,
255261 status = status ,
@@ -262,7 +268,9 @@ def test_unknown_error(self):
262268 msg = "Unknown error type"
263269 ip = "1.2.3.19"
264270 body = {"error" : msg , "code" : "UNKNOWN_TYPE" }
265- self .httpserver .expect_request ("/geoip/v2.1/country/" + ip ).respond_with_json (
271+ self .httpserver .expect_request (
272+ "/geoip/v2.1/country/" + ip , method = "GET"
273+ ).respond_with_json (
266274 body ,
267275 status = 400 ,
268276 content_type = self ._content_type ("country" ),
@@ -271,14 +279,17 @@ def test_unknown_error(self):
271279 self .run_client (self .client .country (ip ))
272280
273281 def test_request (self ):
274- matcher = HeaderValueMatcher ({
275- "Accept" : "application/json" ,
276- "Authorization" :"Basic NDI6YWJjZGVmMTIzNDU2" ,
277- "User-Agent" : lambda x : x .startswith ("GeoIP2-Python-Client/" ),})
282+ matcher = HeaderValueMatcher (
283+ {
284+ "Accept" : "application/json" ,
285+ "Authorization" : "Basic NDI6YWJjZGVmMTIzNDU2" ,
286+ "User-Agent" : lambda x : x .startswith ("GeoIP2-Python-Client/" ),
287+ }
288+ )
278289 self .httpserver .expect_request (
279290 "/geoip/v2.1/country/1.2.3.4" ,
291+ method = "GET" ,
280292 header_value_matcher = matcher ,
281-
282293 ).respond_with_json (
283294 self .country ,
284295 status = 200 ,
@@ -287,7 +298,9 @@ def test_request(self):
287298 self .run_client (self .client .country ("1.2.3.4" ))
288299
289300 def test_city_ok (self ):
290- self .httpserver .expect_request ("/geoip/v2.1/city/1.2.3.4" ).respond_with_json (
301+ self .httpserver .expect_request (
302+ "/geoip/v2.1/city/1.2.3.4" , method = "GET"
303+ ).respond_with_json (
291304 self .country ,
292305 status = 200 ,
293306 content_type = self ._content_type ("city" ),
@@ -301,7 +314,7 @@ def test_city_ok(self):
301314
302315 def test_insights_ok (self ):
303316 self .httpserver .expect_request (
304- "/geoip/v2.1/insights/1.2.3.4"
317+ "/geoip/v2.1/insights/1.2.3.4" , method = "GET"
305318 ).respond_with_json (
306319 self .insights ,
307320 status = 200 ,
0 commit comments