From cea6dd43ef847a4b91d858c1b7639b256b2979f4 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 26 Apr 2020 11:35:36 -0700 Subject: [PATCH] Custom content-type test --- tests/test_custom_pages.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_custom_pages.py b/tests/test_custom_pages.py index bd2c427b..871dd69c 100644 --- a/tests/test_custom_pages.py +++ b/tests/test_custom_pages.py @@ -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") }}', "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 "" == response.text + + def test_redirect(custom_pages_client): response = custom_pages_client.get("/redirect", allow_redirects=False) assert 302 == response.status