Skip to content

Commit

Permalink
aiohttp: Add tests to aiohttp allow_redirects option
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloromeira authored and jairhenrique committed Apr 19, 2022
1 parent 3da66c8 commit 7e73085
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/integration/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,19 @@ async def run(loop):
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

0 comments on commit 7e73085

Please sign in to comment.