deer-flow/backend/tests/test_composition.py
rayhpeng 8e07bd0159 refactor(app): extract the composition root into a pure function
Wiring moves out of deps.py::langgraph_runtime into
app/composition.py::build_domain_services, so the rule the assembly owns
-- a memory database backend yields no services and the routes answer
503 -- is an assertion in tests/test_composition.py instead of a comment
inside the lifespan.
2026-07-29 18:29:04 +08:00

24 lines
890 B
Python

"""Composition-root tests -- the rules the wiring itself owns.
``build_domain_services`` was extracted into a pure function precisely so
these rules are assertions instead of a comment inside the lifespan:
a ``database.backend: memory`` deployment gets no services (the dependency
providers translate that into 503).
"""
from app.composition import build_domain_services
class TestMemoryBackend:
def test_no_sql_backend_means_no_services(self):
services = build_domain_services(session_factory=None, run_store=object())
assert services.feedback is None
class TestSqlBackend:
def test_services_are_assembled(self):
# A bare object suffices: the factory is only handed to adapters,
# never called during assembly.
services = build_domain_services(session_factory=object(), run_store=object())
assert services.feedback is not None