from __future__ import annotations from pathlib import Path from django.test import SimpleTestCase class AdapterBoundaryRulesTests(SimpleTestCase): def test_client_adapters_do_not_import_business_engines(self): clients_dir = Path(__file__).resolve().parents[1] / "clients" banned_prefixes = ( "from core.commands", "import core.commands", "from core.tasks", "import core.tasks", "from core.assist", "import core.assist", "from core.translation", "import core.translation", ) violations = [] for file_path in sorted(clients_dir.glob("*.py")): if file_path.name == "__init__.py": continue content = file_path.read_text(encoding="utf-8") for line_no, line in enumerate(content.splitlines(), start=1): stripped = line.strip() if any(stripped.startswith(prefix) for prefix in banned_prefixes): violations.append(f"{file_path.name}:{line_no}: {stripped}") self.assertEqual( [], violations, msg=( "Adapter modules must stay translator-only and must not import " "business policy/task/assist/translation engines directly." ), )