@@ -66,7 +66,9 @@ def setup_httpserver(self, httpserver: pytest_httpserver.HTTPServer):
66
66
self .httpserver = httpserver
67
67
68
68
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 (
70
72
self .country ,
71
73
status = 200 ,
72
74
content_type = self ._content_type ("country" ),
@@ -110,7 +112,9 @@ def test_country_ok(self):
110
112
self .assertEqual (country .raw , self .country , "raw response is correct" )
111
113
112
114
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 (
114
118
self .country ,
115
119
status = 200 ,
116
120
content_type = self ._content_type ("country" ),
@@ -127,7 +131,9 @@ def test_me(self):
127
131
)
128
132
129
133
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 (
131
137
"" ,
132
138
status = 200 ,
133
139
content_type = self ._content_type ("country" ),
@@ -146,7 +152,7 @@ def test_bad_ip_address(self):
146
152
147
153
def test_no_body_error (self ):
148
154
self .httpserver .expect_request (
149
- "/geoip/v2.1/country/1.2.3.7"
155
+ "/geoip/v2.1/country/1.2.3.7" , method = "GET"
150
156
).respond_with_data (
151
157
"" ,
152
158
status = 400 ,
@@ -160,7 +166,7 @@ def test_no_body_error(self):
160
166
def test_weird_body_error (self ):
161
167
162
168
self .httpserver .expect_request (
163
- "/geoip/v2.1/country/1.2.3.8"
169
+ "/geoip/v2.1/country/1.2.3.8" , method = "GET"
164
170
).respond_with_json (
165
171
{"wierd" : 42 },
166
172
status = 400 ,
@@ -176,7 +182,7 @@ def test_weird_body_error(self):
176
182
def test_bad_body_error (self ):
177
183
178
184
self .httpserver .expect_request (
179
- "/geoip/v2.1/country/1.2.3.9"
185
+ "/geoip/v2.1/country/1.2.3.9" , method = "GET"
180
186
).respond_with_data (
181
187
"bad body" ,
182
188
status = 400 ,
@@ -189,7 +195,7 @@ def test_bad_body_error(self):
189
195
190
196
def test_500_error (self ):
191
197
self .httpserver .expect_request (
192
- "/geoip/v2.1/country/1.2.3.10"
198
+ "/geoip/v2.1/country/1.2.3.10" , method = "GET"
193
199
).respond_with_data (
194
200
"" ,
195
201
status = 500 ,
@@ -201,7 +207,7 @@ def test_500_error(self):
201
207
def test_300_error (self ):
202
208
203
209
self .httpserver .expect_request (
204
- "/geoip/v2.1/country/1.2.3.11"
210
+ "/geoip/v2.1/country/1.2.3.11" , method = "GET"
205
211
).respond_with_data (
206
212
"" ,
207
213
status = 300 ,
@@ -249,7 +255,7 @@ def _test_error(self, status, error_code, error_class):
249
255
msg = "Some error message"
250
256
body = {"error" : msg , "code" : error_code }
251
257
self .httpserver .expect_request (
252
- "/geoip/v2.1/country/1.2.3.18"
258
+ "/geoip/v2.1/country/1.2.3.18" , method = "GET"
253
259
).respond_with_json (
254
260
body ,
255
261
status = status ,
@@ -262,7 +268,9 @@ def test_unknown_error(self):
262
268
msg = "Unknown error type"
263
269
ip = "1.2.3.19"
264
270
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 (
266
274
body ,
267
275
status = 400 ,
268
276
content_type = self ._content_type ("country" ),
@@ -271,14 +279,17 @@ def test_unknown_error(self):
271
279
self .run_client (self .client .country (ip ))
272
280
273
281
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
+ )
278
289
self .httpserver .expect_request (
279
290
"/geoip/v2.1/country/1.2.3.4" ,
291
+ method = "GET" ,
280
292
header_value_matcher = matcher ,
281
-
282
293
).respond_with_json (
283
294
self .country ,
284
295
status = 200 ,
@@ -287,7 +298,9 @@ def test_request(self):
287
298
self .run_client (self .client .country ("1.2.3.4" ))
288
299
289
300
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 (
291
304
self .country ,
292
305
status = 200 ,
293
306
content_type = self ._content_type ("city" ),
@@ -301,7 +314,7 @@ def test_city_ok(self):
301
314
302
315
def test_insights_ok (self ):
303
316
self .httpserver .expect_request (
304
- "/geoip/v2.1/insights/1.2.3.4"
317
+ "/geoip/v2.1/insights/1.2.3.4" , method = "GET"
305
318
).respond_with_json (
306
319
self .insights ,
307
320
status = 200 ,
0 commit comments