From 7e73085331f67db8bd86e0812356f25b776afdfe Mon Sep 17 00:00:00 2001 From: Paulo Romeira Date: Mon, 27 Jul 2020 02:46:39 -0300 Subject: [PATCH] aiohttp: Add tests to aiohttp allow_redirects option --- tests/integration/test_aiohttp.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/integration/test_aiohttp.py b/tests/integration/test_aiohttp.py index 0c665d5..55f21b7 100644 --- a/tests/integration/test_aiohttp.py +++ b/tests/integration/test_aiohttp.py @@ -399,3 +399,19 @@ def test_cookies_redirect(scheme, tmpdir): assert cookies["Cookie_1"].value == "Val_1" run_in_loop(run) + + +def test_not_allow_redirects(tmpdir): + url = "https://mockbin.org/redirect/308/5" + path = str(tmpdir.join("redirects.yaml")) + + with vcr.use_cassette(path): + response, _ = get(url, allow_redirects=False) + assert response.url.path == "/redirect/308/5" + assert response.status == 308 + + with vcr.use_cassette(path) as cassette: + response, _ = get(url, allow_redirects=False) + assert response.url.path == "/redirect/308/5" + assert response.status == 308 + assert cassette.play_count == 1