feat: add messaging transport rollout
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""HTTP表면 0 회귀 가드 (REQ-025).
|
||||
|
||||
본 테스트는 데몬 import 그래프에 fastapi/uvicorn/starlette 가 0건임을
|
||||
정적으로 가드한다. 또한 pyproject.toml 의 runtime 의존성에서 이들이
|
||||
제거되어 있는지 확인한다.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
_REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def test_daemon_module_has_no_fastapi_or_uvicorn_import():
|
||||
# Importing the daemon must not pull in FastAPI/uvicorn/starlette anywhere
|
||||
# in the transitive trex_core graph.
|
||||
for forbidden in ("fastapi", "uvicorn", "starlette"):
|
||||
sys.modules.pop(forbidden, None)
|
||||
importlib.invalidate_caches()
|
||||
importlib.import_module("trex_core.runtime.daemon")
|
||||
# Walk all loaded trex_core.* modules and assert none triggered a forbidden import.
|
||||
leaked = [name for name in ("fastapi", "uvicorn", "starlette") if name in sys.modules]
|
||||
assert leaked == [], f"forbidden HTTP framework imports leaked: {leaked}"
|
||||
|
||||
|
||||
def test_adapters_api_tree_does_not_exist():
|
||||
assert not (_REPO_ROOT / "trex_core" / "adapters" / "api").exists(), (
|
||||
"trex_core/adapters/api must be removed (REQ-025 AC-1)"
|
||||
)
|
||||
|
||||
|
||||
def test_no_fastapi_or_uvicorn_in_trex_core_source():
|
||||
"""grep all .py under trex_core/ — must be 0 matches for fastapi/uvicorn."""
|
||||
pattern_files: list[Path] = []
|
||||
for py in (_REPO_ROOT / "trex_core").rglob("*.py"):
|
||||
text = py.read_text()
|
||||
if any(token in text for token in ("import fastapi", "from fastapi",
|
||||
"import uvicorn", "from uvicorn",
|
||||
"import starlette", "from starlette")):
|
||||
pattern_files.append(py.relative_to(_REPO_ROOT))
|
||||
assert pattern_files == [], f"fastapi/uvicorn imports leaked into: {pattern_files}"
|
||||
|
||||
|
||||
def test_pyproject_dependencies_have_no_fastapi_or_uvicorn():
|
||||
pyproject = (_REPO_ROOT / "pyproject.toml").read_text()
|
||||
# naive substring check is sufficient — we're guarding a removal, not parsing
|
||||
assert "fastapi" not in pyproject, "fastapi must be removed from pyproject.toml"
|
||||
assert "uvicorn" not in pyproject, "uvicorn must be removed from pyproject.toml"
|
||||
|
||||
|
||||
def test_config_env_no_longer_references_api_host_or_port():
|
||||
"""DaemonConfig must not read TREX_API_HOST/PORT (REQ-025 AC-3)."""
|
||||
cfg_src = (_REPO_ROOT / "trex_core" / "runtime" / "config.py").read_text()
|
||||
assert "TREX_API_HOST" not in cfg_src
|
||||
assert "TREX_API_PORT" not in cfg_src
|
||||
Reference in New Issue
Block a user