2026-10-11 15:05:42 +03:00
|
|
|
"""The project's own pages. Every one of them has to follow the spec."""
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
refactor: split the repo into self-contained validator, directory, quickstart, spec and site folders
validator/ holds mewslint (lint, css, fetch, DTD/CSS data); directory/ holds
the mews.page service (app, db, check, pages, cli) and depends on validator/;
quickstart/ holds mews-quickstart and md2mews.py for third parties who want
to create Mews content without cloning the repo; spec/ consolidates doc/ and
dtd/ with the canonical mews-0.1.css; site/ becomes a Pelican project with
the forward-facing pages as Markdown, the check form kept as a raw HTML
snippet. Root pyproject.toml is now a virtual uv workspace over validator,
directory and quickstart, with cross-cutting tests that span more than one
of them staying at the repo root. Makefile and flake.nix updated to match.
2026-10-13 12:29:23 +03:00
|
|
|
import shutil
|
2026-10-11 15:05:42 +03:00
|
|
|
import subprocess
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from mews.lint import validate_file
|
|
|
|
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
refactor: split the repo into self-contained validator, directory, quickstart, spec and site folders
validator/ holds mewslint (lint, css, fetch, DTD/CSS data); directory/ holds
the mews.page service (app, db, check, pages, cli) and depends on validator/;
quickstart/ holds mews-quickstart and md2mews.py for third parties who want
to create Mews content without cloning the repo; spec/ consolidates doc/ and
dtd/ with the canonical mews-0.1.css; site/ becomes a Pelican project with
the forward-facing pages as Markdown, the check form kept as a raw HTML
snippet. Root pyproject.toml is now a virtual uv workspace over validator,
directory and quickstart, with cross-cutting tests that span more than one
of them staying at the repo root. Makefile and flake.nix updated to match.
2026-10-13 12:29:23 +03:00
|
|
|
SITE = ROOT / "site"
|
2026-10-11 15:05:42 +03:00
|
|
|
|
|
|
|
|
|
refactor: split the repo into self-contained validator, directory, quickstart, spec and site folders
validator/ holds mewslint (lint, css, fetch, DTD/CSS data); directory/ holds
the mews.page service (app, db, check, pages, cli) and depends on validator/;
quickstart/ holds mews-quickstart and md2mews.py for third parties who want
to create Mews content without cloning the repo; spec/ consolidates doc/ and
dtd/ with the canonical mews-0.1.css; site/ becomes a Pelican project with
the forward-facing pages as Markdown, the check form kept as a raw HTML
snippet. Root pyproject.toml is now a virtual uv workspace over validator,
directory and quickstart, with cross-cutting tests that span more than one
of them staying at the repo root. Makefile and flake.nix updated to match.
2026-10-13 12:29:23 +03:00
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
|
def built_site():
|
|
|
|
|
"""Build the Pelican site once per test session, and return its output dir."""
|
|
|
|
|
result = subprocess.run(
|
|
|
|
|
[shutil.which("uv"), "run", "pelican", "content", "-o", "output"],
|
|
|
|
|
cwd=SITE,
|
|
|
|
|
capture_output=True,
|
|
|
|
|
text=True,
|
|
|
|
|
check=False,
|
|
|
|
|
)
|
|
|
|
|
assert result.returncode == 0, result.stderr
|
|
|
|
|
return SITE / "output"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(shutil.which("uv") is None, reason="uv is not installed")
|
|
|
|
|
@pytest.mark.slow
|
|
|
|
|
def test_the_sites_own_pages_conform(built_site):
|
|
|
|
|
pages = sorted(built_site.glob("*.html"))
|
|
|
|
|
assert pages, "the site build produced no pages"
|
|
|
|
|
for page in pages:
|
|
|
|
|
report = validate_file(str(page))
|
|
|
|
|
assert report.conforms, "\n".join(str(f) for f in report.failures)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(shutil.which("uv") is None, reason="uv is not installed")
|
|
|
|
|
@pytest.mark.slow
|
|
|
|
|
def test_the_sites_own_pages_have_no_warnings_either(built_site):
|
|
|
|
|
for page in sorted(built_site.glob("*.html")):
|
|
|
|
|
report = validate_file(str(page))
|
|
|
|
|
assert not report.warnings, "\n".join(str(f) for f in report.warnings)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_the_sample_page_conforms():
|
|
|
|
|
report = validate_file(str(ROOT / "sample" / "sample.html"))
|
2026-10-11 15:05:42 +03:00
|
|
|
assert report.conforms, "\n".join(str(f) for f in report.failures)
|
|
|
|
|
|
|
|
|
|
|
refactor: split the repo into self-contained validator, directory, quickstart, spec and site folders
validator/ holds mewslint (lint, css, fetch, DTD/CSS data); directory/ holds
the mews.page service (app, db, check, pages, cli) and depends on validator/;
quickstart/ holds mews-quickstart and md2mews.py for third parties who want
to create Mews content without cloning the repo; spec/ consolidates doc/ and
dtd/ with the canonical mews-0.1.css; site/ becomes a Pelican project with
the forward-facing pages as Markdown, the check form kept as a raw HTML
snippet. Root pyproject.toml is now a virtual uv workspace over validator,
directory and quickstart, with cross-cutting tests that span more than one
of them staying at the repo root. Makefile and flake.nix updated to match.
2026-10-13 12:29:23 +03:00
|
|
|
def test_the_sample_page_has_no_warnings_either():
|
|
|
|
|
report = validate_file(str(ROOT / "sample" / "sample.html"))
|
2026-10-11 15:05:42 +03:00
|
|
|
assert not report.warnings, "\n".join(str(f) for f in report.warnings)
|
|
|
|
|
|
|
|
|
|
|
2026-10-11 20:55:07 +03:00
|
|
|
PLUGIN_PAGES = sorted(
|
|
|
|
|
(ROOT / "pelican-mews" / "tests" / "fixtures").glob("*/expected.xhtml")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("page", PLUGIN_PAGES, ids=lambda p: p.parent.name)
|
|
|
|
|
def test_pages_the_pelican_plugin_produces_conform(page):
|
|
|
|
|
"""What the plugin writes has to pass the validator, or it is no use."""
|
|
|
|
|
report = validate_file(str(page))
|
|
|
|
|
assert report.conforms, "\n".join(str(f) for f in report.failures)
|
|
|
|
|
|
|
|
|
|
|
2026-10-11 15:05:42 +03:00
|
|
|
def test_the_dtd_still_matches_the_spec():
|
refactor: split the repo into self-contained validator, directory, quickstart, spec and site folders
validator/ holds mewslint (lint, css, fetch, DTD/CSS data); directory/ holds
the mews.page service (app, db, check, pages, cli) and depends on validator/;
quickstart/ holds mews-quickstart and md2mews.py for third parties who want
to create Mews content without cloning the repo; spec/ consolidates doc/ and
dtd/ with the canonical mews-0.1.css; site/ becomes a Pelican project with
the forward-facing pages as Markdown, the check form kept as a raw HTML
snippet. Root pyproject.toml is now a virtual uv workspace over validator,
directory and quickstart, with cross-cutting tests that span more than one
of them staying at the repo root. Makefile and flake.nix updated to match.
2026-10-13 12:29:23 +03:00
|
|
|
"""spec/check_dtd.py is hand-maintained; keep it running in CI."""
|
2026-10-11 15:05:42 +03:00
|
|
|
result = subprocess.run(
|
refactor: split the repo into self-contained validator, directory, quickstart, spec and site folders
validator/ holds mewslint (lint, css, fetch, DTD/CSS data); directory/ holds
the mews.page service (app, db, check, pages, cli) and depends on validator/;
quickstart/ holds mews-quickstart and md2mews.py for third parties who want
to create Mews content without cloning the repo; spec/ consolidates doc/ and
dtd/ with the canonical mews-0.1.css; site/ becomes a Pelican project with
the forward-facing pages as Markdown, the check form kept as a raw HTML
snippet. Root pyproject.toml is now a virtual uv workspace over validator,
directory and quickstart, with cross-cutting tests that span more than one
of them staying at the repo root. Makefile and flake.nix updated to match.
2026-10-13 12:29:23 +03:00
|
|
|
[sys.executable, str(ROOT / "spec" / "check_dtd.py")],
|
2026-10-11 15:05:42 +03:00
|
|
|
capture_output=True,
|
|
|
|
|
text=True,
|
|
|
|
|
check=False,
|
|
|
|
|
)
|
|
|
|
|
assert result.returncode == 0, result.stderr
|