1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

tests/aiohttp: Add cookies test

This commit is contained in:
Paulo Romeira
2020-06-03 21:42:11 -03:00
committed by Kevin McCarthy
parent 438550959f
commit 062126e50c

View File

@@ -1,5 +1,6 @@
import contextlib
import logging
import urllib.parse
import pytest
@@ -319,3 +320,23 @@ def test_double_requests(tmpdir):
# Now that we made both requests, we should have played both.
assert cassette.play_count == 2
def test_cookies(scheme, tmpdir):
url = scheme + (
'://httpbin.org/response-headers?'
'set-cookie=' + urllib.parse.quote('cookie_1=val_1; Path=/') + '&'
'Set-Cookie=' + urllib.parse.quote('Cookie_2=Val_2; Path=/')
)
with vcr.use_cassette(str(tmpdir.join("cookies.yaml"))) as cassette:
response, _ = get(url, output='json')
assert response.cookies.get('cookie_1').value == 'val_1'
assert response.cookies.get('Cookie_2').value == 'Val_2'
with vcr.use_cassette(str(tmpdir.join("cookies.yaml"))) as cassette:
response, _ = get(url, output='json')
assert cassette.play_count == 1
assert response.cookies.get('cookie_1').value == 'val_1'
assert response.cookies.get('Cookie_2').value == 'Val_2'