Skip to content

Commit

Permalink
[PR #9065/b6196e7 backport][3.11] Add coverage for combining an exist…
Browse files Browse the repository at this point in the history
…ing query string with params (#9067)
  • Loading branch information
bdraco committed Sep 8, 2024
1 parent 2d6898a commit e34f91b
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,41 @@ async def handler(request):
assert 200 == resp.status


async def test_drop_params_on_redirect(aiohttp_client) -> None:
async def handler_redirect(request):
async def test_params_and_query_string(aiohttp_client: AiohttpClient) -> None:
"""Test combining params with an existing query_string."""

async def handler(request: web.Request) -> web.Response:
assert request.rel_url.query_string == "q=abc&q=test&d=dog"
return web.Response()

app = web.Application()
app.router.add_route("GET", "/", handler)
client = await aiohttp_client(app)

async with client.get("/?q=abc", params="q=test&d=dog") as resp:
assert resp.status == 200


@pytest.mark.parametrize("params", [None, "", {}, MultiDict()])
async def test_empty_params_and_query_string(
aiohttp_client: AiohttpClient, params: Any
) -> None:
"""Test combining empty params with an existing query_string."""

async def handler(request: web.Request) -> web.Response:
assert request.rel_url.query_string == "q=abc"
return web.Response()

app = web.Application()
app.router.add_route("GET", "/", handler)
client = await aiohttp_client(app)

async with client.get("/?q=abc", params=params) as resp:
assert resp.status == 200


async def test_drop_params_on_redirect(aiohttp_client: AiohttpClient) -> None:
async def handler_redirect(request: web.Request) -> web.Response:
return web.Response(status=301, headers={"Location": "/ok?a=redirect"})

async def handler_ok(request):
Expand Down

0 comments on commit e34f91b

Please sign in to comment.