from src.build import Build from src.config import Config from src.pages import NOINDEX_DIRECTIVES def write_site(tmp_path): (tmp_path / "toc").mkdir() (tmp_path / "contents" / "static").mkdir(parents=True) (tmp_path / "contents" / "snippets").mkdir(parents=True) (tmp_path / "contents" / "static" / "kontakt.html").write_text( "

Kontakt

hemlig@example.se", encoding="utf-8" ) (tmp_path / "contents" / "static" / "info.html").write_text("

Info

", encoding="utf-8") (tmp_path / "contents" / "snippets" / "footer_operator.md").write_text( 'Ansvarig: Test (SA0TST) · Kontakt\n', encoding="utf-8" ) def test_contact_page_is_noindex_and_listed_in_robots_txt(tmp_path): write_site(tmp_path) Build(Config(content_path=tmp_path, build_path=tmp_path / "build")).build_website() out = tmp_path / "build" robots = (out / "robots.txt").read_text(encoding="utf-8") assert "User-agent: *" in robots assert "Allow: /\n" in robots assert "Disallow: /kontakt.html" in robots assert "Disallow: /info.html" not in robots # normal pages stay indexable assert f'' in (out / "kontakt.html").read_text(encoding="utf-8") assert 'name="robots"' not in (out / "info.html").read_text(encoding="utf-8") def test_footer_names_operator_without_contact_details(tmp_path): write_site(tmp_path) Build(Config(content_path=tmp_path, build_path=tmp_path / "build")).build_website() info = (tmp_path / "build" / "info.html").read_text(encoding="utf-8") assert "Ansvarig: Test (SA0TST)" in info assert 'href="kontakt.html"' in info assert "hemlig@example.se" not in info def test_no_footer_operator_without_snippet(tmp_path): write_site(tmp_path) (tmp_path / "contents" / "snippets" / "footer_operator.md").unlink() Build(Config(content_path=tmp_path, build_path=tmp_path / "build")).build_website() assert "Ansvarig" not in (tmp_path / "build" / "info.html").read_text(encoding="utf-8")