Custom content-type test

This commit is contained in:
Simon Willison 2020-04-26 11:35:36 -07:00
commit cea6dd43ef

View file

@ -25,6 +25,9 @@ def custom_pages_client(tmp_path_factory):
'{{ custom_header("x-this-is-bar", "bar") }}BAR',
"utf-8",
)
(pages_dir / "atom.html").write_text(
'{{ custom_header("content-type", "application/xml") }}<?xml ...>', "utf-8",
)
(pages_dir / "redirect.html").write_text(
'{{ custom_redirect("/example") }}', "utf-8"
)
@ -68,6 +71,13 @@ def test_custom_headers(custom_pages_client):
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):
response = custom_pages_client.get("/redirect", allow_redirects=False)
assert 302 == response.status