2026-10-05 09:41:22 +02:00
|
|
|
# retoor <retoor@molodetz.nl>
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2026-10-05 11:25:41 +02:00
|
|
|
PUBLIC_PAGES = ["/", "/roll", "/standard", "/flyers", "/memes", "/people", "/people/retoor", "/join", "/docs", "/docs/welcome", "/docs/api/content", "/docs/search?q=markdown", "/terms", "/privacy", "/auth/login"]
|
|
|
|
|
JSON_PAGES = ["/", "/roll", "/standard", "/flyers", "/memes", "/people", "/join"]
|
2026-10-05 09:41:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("path", PUBLIC_PAGES)
|
|
|
|
|
def test_public_pages_return_200(anon, path):
|
|
|
|
|
response = anon.get(path)
|
|
|
|
|
assert response.status_code == 200, path
|
|
|
|
|
assert "text/html" in response.headers["content-type"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("path", JSON_PAGES)
|
|
|
|
|
def test_json_faces(anon, path):
|
|
|
|
|
response = anon.get(path, headers={"Accept": "application/json"})
|
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
assert response.headers["content-type"].startswith("application/json")
|
|
|
|
|
assert isinstance(response.json(), dict)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_no_bare_static_urls_in_rendered_html(anon):
|
2026-10-05 11:25:41 +02:00
|
|
|
for path in ("/", "/flyers", "/memes", "/roll"):
|
2026-10-05 09:41:22 +02:00
|
|
|
html = anon.get(path).text
|
|
|
|
|
assert not re.search(r"""(src|href)="/static/(?!v|uploads/)""", html), path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_versioned_static_asset(anon):
|
|
|
|
|
html = anon.get("/").text
|
|
|
|
|
match = re.search(r'href="(/static/v[^"]+/css/base\.css)"', html)
|
|
|
|
|
assert match
|
|
|
|
|
assert anon.get(match.group(1)).status_code == 200
|