mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Docs + unit tests for Response, closes #821
This commit is contained in:
parent
f5e79adf26
commit
db660db463
4 changed files with 86 additions and 1 deletions
28
tests/test_internals_response.py
Normal file
28
tests/test_internals_response.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from datasette.utils.asgi import Response
|
||||
|
||||
|
||||
def test_response_html():
|
||||
response = Response.html("Hello from HTML")
|
||||
assert 200 == response.status
|
||||
assert "Hello from HTML" == response.body
|
||||
assert "text/html; charset=utf-8" == response.content_type
|
||||
|
||||
|
||||
def test_response_text():
|
||||
response = Response.text("Hello from text")
|
||||
assert 200 == response.status
|
||||
assert "Hello from text" == response.body
|
||||
assert "text/plain; charset=utf-8" == response.content_type
|
||||
|
||||
|
||||
def test_response_json():
|
||||
response = Response.json({"this_is": "json"})
|
||||
assert 200 == response.status
|
||||
assert '{"this_is": "json"}' == response.body
|
||||
assert "application/json; charset=utf-8" == response.content_type
|
||||
|
||||
|
||||
def test_response_redirect():
|
||||
response = Response.redirect("/foo")
|
||||
assert 302 == response.status
|
||||
assert "/foo" == response.headers["Location"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue