Files
plm-lottery/tests/django/test_engine_package.py
T
davideandClaude Sonnet 5.5 3ee60a23da B1: plm_engine takes the modules without a database (ADR-59)
HD derivation (pure part), PSBT builder, Electrum client/merkle/quorum/scripthash, network
profile, addresses and header checks move to plm_engine; the old stack imports them from
there. A test forbids framework imports in the package.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 15:31:47 +01:00

22 lines
908 B
Python

"""B1 — `plm_engine` is framework-free: it never imports Django, the old FastAPI stack or a database layer (ADR-59)."""
import ast
from pathlib import Path
import pytest
ENGINE = Path(__file__).resolve().parents[2] / "plm_engine"
FORBIDDEN = {"django", "apps", "app", "config", "sqlalchemy", "fastapi", "alembic"}
@pytest.mark.parametrize("path", sorted(ENGINE.rglob("*.py")), ids=lambda p: str(p.relative_to(ENGINE)))
def test_the_engine_imports_no_framework(path):
tree = ast.parse(path.read_text())
imported = set()
for node in ast.walk(tree):
if isinstance(node, ast.Import):
imported |= {alias.name.split(".")[0] for alias in node.names}
elif isinstance(node, ast.ImportFrom) and node.level == 0 and node.module:
imported.add(node.module.split(".")[0])
assert not imported & FORBIDDEN, f"{path.name} imports {sorted(imported & FORBIDDEN)}"