mirror of
https://github.com/RunLit/Bambu-Run.git
synced 2026-10-21 23:39:01 +01:00
feat(mcp): assemble the 8-tool toolkit with capability gating, proven via real dispatch
Also fixes async-test DB isolation: test_mcp_toolkit.py drives real MCP dispatch, which runs tool functions' ORM calls on a sync_to_async worker thread outside pytest-django's per-test atomic transaction, so writes committed there weren't rolled back and leaked into later tests. Sets DJANGO_ALLOW_ASYNC_UNSAFE for the async ORM setup calls and flushes the Printer table after this file's tests via conftest.py.
This commit is contained in:
@@ -1,4 +1,16 @@
|
||||
"""Minimal Django settings for running bambu_run's pytest suite (in-memory SQLite)."""
|
||||
import os
|
||||
|
||||
# test_mcp_toolkit.py drives real MCP dispatch through `mcp.client.Client`,
|
||||
# which runs the test body on the asyncio event loop (via pytest-anyio) while
|
||||
# still using plain synchronous Django ORM calls (Printer.objects.create(),
|
||||
# and the ORM calls inside the tool functions themselves). Django's asyncio
|
||||
# safety net treats any sync ORM call made while an event loop is running as
|
||||
# unsafe by default. It's genuinely safe here: sqlite is in-memory, tests run
|
||||
# single-threaded, and there's no concurrent request interleaving to corrupt
|
||||
# a shared connection. Set at settings-import time (before any test body
|
||||
# runs) rather than per-test, since Django reads this env var at call time.
|
||||
os.environ.setdefault("DJANGO_ALLOW_ASYNC_UNSAFE", "1")
|
||||
|
||||
SECRET_KEY = "test-secret-key"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user