"""Layering / dependency checks."""
from pathlib import Path


def test_api_modules_do_not_import_models_directly():
    api_root = Path(__file__).resolve().parents[1] / "api" / "v1"
    for path in api_root.glob("*.py"):
        if path.name == "__init__.py":
            continue
        text = path.read_text(encoding="utf-8")
        assert "from app.models" not in text, path.name
        assert "import app.models" not in text, path.name


def test_repositories_do_not_import_services():
    repo_root = Path(__file__).resolve().parents[1] / "repositories"
    for path in repo_root.glob("*.py"):
        text = path.read_text(encoding="utf-8")
        assert "from app.services" not in text, path.name
