"""Validate that path documentation READMEs exist and have required sections (REQ-97, 98, 99)."""

from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent


class TestDocsCoverage:
    def test_schemas_readme_exists(self):
        assert (ROOT / "schemas" / "README.md").is_file()

    def test_schemas_readme_has_required_sections(self):
        content = open(ROOT / "schemas" / "README.md").read()
        assert "How to Write a Schema" in content
        assert "How to Wire" in content
        assert "How to Test" in content
        assert "Existing Schemas" in content

    def test_pipelines_readme_exists(self):
        assert (ROOT / "pipelines" / "README.md").is_file()

    def test_pipelines_readme_has_required_sections(self):
        content = open(ROOT / "pipelines" / "README.md").read()
        assert "How to Write a Pipeline" in content
        assert "How to Wire" in content
        assert "How to Test" in content
        assert "Existing Pipelines" in content

    def test_adapters_readme_exists(self):
        assert (ROOT / "adapters" / "README.md").is_file()

    def test_adapters_readme_has_required_sections(self):
        content = open(ROOT / "adapters" / "README.md").read()
        assert "How to Write an Adapter" in content
        assert "How to Wire" in content
        assert "How to Test" in content
        assert "Existing Adapters" in content

def test_github_workflows_readme_catalogs_all_workflows():
    """P16 (REQ-180): .github/workflows/README.md catalogs all 7 workflows."""
    from pathlib import Path
    readme = Path(__file__).resolve().parent.parent / ".github" / "workflows" / "README.md"
    assert readme.is_file(), ".github/workflows/README.md missing"
    text = readme.read_text()
    for wf in ["ci.yml", "deploy.yml", "modules-lifecycle.yml",
               "platform-test.yml", "primitives-plan.yml", "patterns-plan.yml",
               "release.yml"]:
        assert wf in text, f"{wf} not cataloged in .github/workflows/README.md"
