"""Versione e commit nel piede di pagina (#70).""" import tomllib from pathlib import Path from config import Config _PYPROJECT = Path(__file__).resolve().parents[4] / "pyproject.toml" def _pyproject_version() -> str: with _PYPROJECT.open("rb") as fh: return tomllib.load(fh)["project"]["version"] def test_app_version_matches_pyproject(): # La versione mostrata e' quella di pyproject.toml, non un valore a mano assert Config.APP_VERSION == _pyproject_version() def test_login_page_shows_version(client): resp = client.get("/auth/login") assert resp.status_code == 200 assert f"v{_pyproject_version()}" in resp.get_data(as_text=True) def test_login_page_shows_commit_when_set(client, monkeypatch): # Commit valorizzato (gia' troncato a 7 da Config): compare nel footer monkeypatch.setattr(Config, "APP_COMMIT", "abc1234") assert "abc1234" in client.get("/auth/login").get_data(as_text=True) def test_login_page_hides_commit_when_empty(client, monkeypatch): # Build senza APP_COMMIT: solo versione, nessun separatore orfano monkeypatch.setattr(Config, "APP_COMMIT", "") html = client.get("/auth/login").get_data(as_text=True) assert f"v{_pyproject_version()}" in html assert f"v{_pyproject_version()} ·" not in html