Skip to content

Commit 8d826dc

Browse files
committed
Update test to use the request object
1 parent 775f1ca commit 8d826dc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tests/webservices_test.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
import httpretty
5+
import httpretty.core
56
import sys
67
sys.path.append('..')
78

@@ -168,17 +169,19 @@ def test_request(self):
168169
body = json.dumps(self.country),
169170
status = 200)
170171
country = self.client.country('1.2.3.4')
171-
args, kwargs = get.call_args
172-
self.assertEqual(args[0], 'https://geoip.maxmind.com'
172+
request = httpretty.core.httpretty.latest_requests[-1]
173+
174+
self.assertEqual(request.path,
173175
'/geoip/v2.0/country/1.2.3.4',
174176
'correct URI is used')
175-
self.assertEqual(kwargs.get('headers').get('Accept'),
177+
self.assertEqual(request.headers['Accept'],
176178
'application/json',
177179
'correct Accept header')
178-
self.assertRegex(kwargs.get('headers').get('User-Agent'),
180+
self.assertRegex(request.headers['User-Agent'],
179181
'^GeoIP2 Python Client v',
180182
'Correct User-Agent')
181-
self.assertEqual(kwargs.get('auth'), (42, 'abcdef123456'))
183+
self.assertEqual(request.headers['Authorization'],
184+
'Basic NDI6YWJjZGVmMTIzNDU2', 'correct auth')
182185

183186
def test_city_ok(self):
184187
httpretty.register_uri(httpretty.GET,

0 commit comments

Comments
 (0)