mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
Test aiohttp usage with query strings on the URL
This commit is contained in:
@@ -137,3 +137,20 @@ def test_params_same_url_distinct_params(tmpdir, scheme):
|
|||||||
response, cassette_response_text = get(url, output='text', params=other_params)
|
response, cassette_response_text = get(url, output='text', params=other_params)
|
||||||
assert 'No match for the request' in cassette_response_text
|
assert 'No match for the request' in cassette_response_text
|
||||||
assert response.status == 599
|
assert response.status == 599
|
||||||
|
|
||||||
|
|
||||||
|
def test_params_on_url(tmpdir, scheme):
|
||||||
|
url = scheme + '://httpbin.org/get?a=1&b=foo'
|
||||||
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('get.yaml'))) as cassette:
|
||||||
|
_, response_json = get(url, output='json', headers=headers)
|
||||||
|
request = cassette.requests[0]
|
||||||
|
assert request.url == url
|
||||||
|
|
||||||
|
with vcr.use_cassette(str(tmpdir.join('get.yaml'))) as cassette:
|
||||||
|
_, cassette_response_json = get(url, output='json', headers=headers)
|
||||||
|
request = cassette.requests[0]
|
||||||
|
assert request.url == url
|
||||||
|
assert cassette_response_json == response_json
|
||||||
|
assert cassette.play_count == 1
|
||||||
|
|||||||
@@ -52,12 +52,11 @@ def vcr_request(cassette, real_request):
|
|||||||
data = kwargs.get('data')
|
data = kwargs.get('data')
|
||||||
params = kwargs.get('params')
|
params = kwargs.get('params')
|
||||||
|
|
||||||
|
request_url = URL(url)
|
||||||
if params:
|
if params:
|
||||||
for k, v in params.items():
|
for k, v in params.items():
|
||||||
params[k] = str(v)
|
params[k] = str(v)
|
||||||
request_url = URL(url).with_query(params)
|
request_url = URL(url).with_query(params)
|
||||||
else:
|
|
||||||
request_url = URL(url)
|
|
||||||
|
|
||||||
vcr_request = Request(method, str(request_url), data, headers)
|
vcr_request = Request(method, str(request_url), data, headers)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user