mirror of
https://github.com/not-kennethreitz/requests-async.git
synced 2026-06-05 23:10:17 +00:00
22 lines
687 B
Python
22 lines
687 B
Python
import requests_async
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_redirects(server):
|
|
url = "http://127.0.0.1:8000/redirect1"
|
|
response = await requests_async.get(url)
|
|
assert response.status_code == 200
|
|
assert response.json() == {"hello": "world"}
|
|
assert response.url == "http://127.0.0.1:8000/redirect3"
|
|
assert len(response.history) == 2
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_redirects_disallowed(server):
|
|
url = "http://127.0.0.1:8000/redirect1"
|
|
response = await requests_async.get(url, allow_redirects=False)
|
|
assert response.status_code == 302
|
|
assert response.url == "http://127.0.0.1:8000/redirect1"
|
|
assert len(response.history) == 0
|