Add body_exists to MockRequest in aiohttp util (#100932)

* Add body_exists to MockRequest in aiohttp util

* Add body_exists to MockRequest in aiohttp util

* Add body_exists to MockRequest in aiohttp util
This commit is contained in:
Joost Lekkerkerker
2023-09-26 17:52:29 +02:00
committed by GitHub
parent 785b46af22
commit 59207be5f8
2 changed files with 13 additions and 1 deletions

View File

@@ -12,12 +12,19 @@ async def test_request_json() -> None:
async def test_request_text() -> None:
"""Test a JSON request."""
"""Test bytes in request."""
request = aiohttp.MockRequest(b"hello", status=201, mock_source="test")
assert request.body_exists
assert request.status == 201
assert await request.text() == "hello"
async def test_request_body_exists() -> None:
"""Test body exists."""
request = aiohttp.MockRequest(b"", mock_source="test")
assert not request.body_exists
async def test_request_post_query() -> None:
"""Test a JSON request."""
request = aiohttp.MockRequest(