mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Custom content-type test
This commit is contained in:
parent
f56022ac9a
commit
cea6dd43ef
1 changed files with 10 additions and 0 deletions
|
|
@ -25,6 +25,9 @@ def custom_pages_client(tmp_path_factory):
|
||||||
'{{ custom_header("x-this-is-bar", "bar") }}BAR',
|
'{{ custom_header("x-this-is-bar", "bar") }}BAR',
|
||||||
"utf-8",
|
"utf-8",
|
||||||
)
|
)
|
||||||
|
(pages_dir / "atom.html").write_text(
|
||||||
|
'{{ custom_header("content-type", "application/xml") }}<?xml ...>', "utf-8",
|
||||||
|
)
|
||||||
(pages_dir / "redirect.html").write_text(
|
(pages_dir / "redirect.html").write_text(
|
||||||
'{{ custom_redirect("/example") }}', "utf-8"
|
'{{ custom_redirect("/example") }}', "utf-8"
|
||||||
)
|
)
|
||||||
|
|
@ -68,6 +71,13 @@ def test_custom_headers(custom_pages_client):
|
||||||
assert "FOOBAR" == response.text
|
assert "FOOBAR" == response.text
|
||||||
|
|
||||||
|
|
||||||
|
def test_custom_content_type(custom_pages_client):
|
||||||
|
response = custom_pages_client.get("/atom")
|
||||||
|
assert 200 == response.status
|
||||||
|
assert response.headers["content-type"] == "application/xml"
|
||||||
|
assert "<?xml ...>" == response.text
|
||||||
|
|
||||||
|
|
||||||
def test_redirect(custom_pages_client):
|
def test_redirect(custom_pages_client):
|
||||||
response = custom_pages_client.get("/redirect", allow_redirects=False)
|
response = custom_pages_client.get("/redirect", allow_redirects=False)
|
||||||
assert 302 == response.status
|
assert 302 == response.status
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue