mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-22 16:06:50 +00:00
refactor(tests): reorganize tests into unittest/ and e2e/ directories
- Move all unit tests from tests/ to tests/unittest/ - Add tests/e2e/ directory for end-to-end tests - Update conftest.py for new test structure - Add new tests for auth dependencies, policies, route injection - Add new tests for run callbacks, create store, execution artifacts - Remove obsolete tests for deleted persistence layer Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
"""Boundary check: harness layer must not import from app layer.
|
||||
|
||||
The deerflow-harness package (packages/harness/deerflow/) is a standalone,
|
||||
publishable agent framework. It must never depend on the app layer (app/).
|
||||
|
||||
This test scans all Python files in the harness package and fails if any
|
||||
``from app.`` or ``import app.`` statement is found.
|
||||
"""
|
||||
|
||||
import ast
|
||||
from pathlib import Path
|
||||
|
||||
HARNESS_ROOT = Path(__file__).parent.parent / "packages" / "harness" / "deerflow"
|
||||
|
||||
BANNED_PREFIXES = ("app.",)
|
||||
|
||||
|
||||
def _collect_imports(filepath: Path) -> list[tuple[int, str]]:
|
||||
"""Return (line_number, module_path) for every import in *filepath*."""
|
||||
source = filepath.read_text(encoding="utf-8")
|
||||
try:
|
||||
tree = ast.parse(source, filename=str(filepath))
|
||||
except SyntaxError:
|
||||
return []
|
||||
|
||||
results: list[tuple[int, str]] = []
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Import):
|
||||
for alias in node.names:
|
||||
results.append((node.lineno, alias.name))
|
||||
elif isinstance(node, ast.ImportFrom):
|
||||
if node.module:
|
||||
results.append((node.lineno, node.module))
|
||||
return results
|
||||
|
||||
|
||||
def test_harness_does_not_import_app():
|
||||
violations: list[str] = []
|
||||
|
||||
for py_file in sorted(HARNESS_ROOT.rglob("*.py")):
|
||||
for lineno, module in _collect_imports(py_file):
|
||||
if any(module == prefix.rstrip(".") or module.startswith(prefix) for prefix in BANNED_PREFIXES):
|
||||
rel = py_file.relative_to(HARNESS_ROOT.parent.parent.parent)
|
||||
violations.append(f" {rel}:{lineno} imports {module}")
|
||||
|
||||
assert not violations, "Harness layer must not import from app layer:\n" + "\n".join(violations)
|
||||
Reference in New Issue
Block a user