await Request(scope, receive).post_vars() method, closes #700

Needed for #698
This commit is contained in:
Simon Willison 2020-03-16 19:47:37 -07:00
commit a000c80d50
2 changed files with 37 additions and 4 deletions

View file

@ -423,3 +423,23 @@ def test_check_connection_spatialite_raises():
def test_check_connection_passes():
conn = sqlite3.connect(":memory:")
utils.check_connection(conn)
@pytest.mark.asyncio
async def test_request_post_vars():
scope = {
"http_version": "1.1",
"method": "POST",
"path": "/",
"raw_path": b"/",
"query_string": b"",
"scheme": "http",
"type": "http",
"headers": [[b"content-type", b"application/x-www-form-urlencoded"]],
}
async def receive():
return {"type": "http.request", "body": b"foo=bar&baz=1", "more_body": False}
request = Request(scope, receive)
assert {"foo": "bar", "baz": "1"} == await request.post_vars()