from __future__ import annotations from pathlib import Path REPOSITORY_ROOT = Path(__file__).parents[1] ENGLISH_DOCUMENTS = ( Path("README.md"), Path("docs/README.md"), Path("docs/agent-loop.md"), Path("docs/architecture.md"), Path("docs/development.md"), Path("docs/experiments.md"), Path("docs/infrastructure.md"), Path("docs/openwebui-integration.md"), Path("docs/operations.md"), Path("docs/project-history.md"), Path("docs/security.md"), ) def _chinese_counterpart(english: Path) -> Path: return english.with_name(f"{english.stem}.zh-CN{english.suffix}") def test_every_project_document_has_a_chinese_counterpart() -> None: for english_relative in ENGLISH_DOCUMENTS: chinese_relative = _chinese_counterpart(english_relative) english = REPOSITORY_ROOT / english_relative chinese = REPOSITORY_ROOT / chinese_relative assert english.is_file(), english_relative assert chinese.is_file(), chinese_relative assert chinese.stat().st_size > 500, chinese_relative assert f"]({chinese.name})" in english.read_text(), english_relative english_link = "README.md" if chinese.name == "README.zh-CN.md" else english.name assert f"]({english_link})" in chinese.read_text(), chinese_relative def test_public_portal_links_to_the_chinese_documentation() -> None: html = (REPOSITORY_ROOT / "docs" / "site" / "index.html").read_text() assert "打开中文文档" in html assert "docs/README.zh-CN.md" in html for relative in ( Path("README.md"), Path("docs/agent-loop.md"), Path("docs/architecture.md"), Path("docs/experiments.md"), Path("docs/operations.md"), Path("docs/security.md"), ): assert _chinese_counterpart(relative).as_posix() in html