cdad6fd641
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (push) Successful in 45s
Deploy / Deploy Staging (push) Successful in 1s
93 lines
3.4 KiB
Python
93 lines
3.4 KiB
Python
from pathlib import Path
|
|
|
|
ALLOWED_API_ADAPTER_IMPORTS = {
|
|
Path("apps/api/app/dependencies.py"),
|
|
Path("apps/api/app/db.py"),
|
|
Path("apps/api/app/api/routes/edit_plans.py"),
|
|
}
|
|
|
|
|
|
def test_api_routes_do_not_import_sqlalchemy_adapters_directly():
|
|
offenders: list[str] = []
|
|
for path in Path("apps/api/app/api/routes").glob("*.py"):
|
|
if path in ALLOWED_API_ADAPTER_IMPORTS:
|
|
continue
|
|
text = path.read_text(encoding="utf-8")
|
|
if "packages.adapters.sqlalchemy_impl" in text or "SQLAlchemy" in text:
|
|
offenders.append(str(path))
|
|
|
|
assert offenders == []
|
|
|
|
|
|
def test_domain_auth_does_not_export_infrastructure_singletons():
|
|
text = Path("packages/domain/auth/__init__.py").read_text(encoding="utf-8")
|
|
|
|
assert "session_store," not in text
|
|
assert "email_service," not in text
|
|
assert '"session_store"' not in text
|
|
assert '"email_service"' not in text
|
|
|
|
|
|
def test_runtime_code_does_not_import_deprecated_postgres_adapters():
|
|
assert not Path("packages/adapters/postgres").exists() or not list(Path("packages/adapters/postgres").glob("*.py"))
|
|
|
|
roots = [Path("apps"), Path("packages"), Path("tests")]
|
|
offenders: list[str] = []
|
|
for root in roots:
|
|
for path in root.rglob("*.py"):
|
|
if path.resolve() == Path(__file__).resolve():
|
|
continue
|
|
if path.parts[:3] == ("packages", "adapters", "postgres"):
|
|
continue
|
|
text = path.read_text(encoding="utf-8")
|
|
if "packages.adapters.postgres" in text or "Postgres" in text:
|
|
offenders.append(str(path))
|
|
|
|
assert offenders == []
|
|
|
|
|
|
def test_canonical_auth_route_has_no_auth_simple_runtime_path():
|
|
assert not Path("apps/api/app/api/routes/auth_simple.py").exists()
|
|
|
|
offenders: list[str] = []
|
|
for root in [Path("apps"), Path("packages"), Path("tests")]:
|
|
for path in root.rglob("*.py"):
|
|
if path.resolve() == Path(__file__).resolve():
|
|
continue
|
|
text = path.read_text(encoding="utf-8")
|
|
if "auth_simple" in text or "routes.auth_simple" in text:
|
|
offenders.append(str(path))
|
|
|
|
assert offenders == []
|
|
|
|
|
|
def test_runtime_code_uses_oss_storage_naming_not_minio():
|
|
allowed = {Path("apps/api/app/core/storage.py")}
|
|
offenders: list[str] = []
|
|
for root in [Path("apps"), Path("packages"), Path("tests")]:
|
|
for path in root.rglob("*.py"):
|
|
if path in allowed or path.resolve() == Path(__file__).resolve():
|
|
continue
|
|
text = path.read_text(encoding="utf-8")
|
|
if "MinIO" in text or "minio" in text or "get_minio_service" in text:
|
|
offenders.append(str(path))
|
|
|
|
assert offenders == []
|
|
|
|
|
|
def test_legacy_sql_schema_files_are_not_runtime_entrypoints():
|
|
init_tables = Path("init-tables.sql").read_text(encoding="utf-8")
|
|
|
|
assert "RAISE EXCEPTION" in init_tables
|
|
assert "deprecated" in init_tables.lower()
|
|
|
|
offenders: list[str] = []
|
|
for root in [Path("apps"), Path("packages"), Path("infra")]:
|
|
for pattern in ("*.py", "*.sh", "*.yml", "*.yaml", "*.md"):
|
|
for path in root.rglob(pattern):
|
|
text = path.read_text(encoding="utf-8", errors="ignore")
|
|
if "init-tables.sql" in text or "migrations/001_initial_schema.sql" in text:
|
|
offenders.append(str(path))
|
|
|
|
assert offenders == []
|