Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
fix(tests): route session_factory's tenant bind through tenant_scope (CHOO-2698)
Wojciech Wojtyniak0a0ee88c8f72
diff --git a/core/tests/conftest.py b/core/tests/conftest.pyindex f0c70cd84..7cdb929ba 100644--- a/core/tests/conftest.py+++ b/core/tests/conftest.py@@ -1,5 +1,6 @@from __future__ import annotations+import contextlibimport uuidfrom collections.abc import AsyncIterator, Iteratorfrom dataclasses import dataclass@@ -24,7 +25,7 @@ from switch_core.db.base import Basefrom switch_core.db.engine import create_session_factoryfrom switch_core.db.models import TENANT_ZERO_ID, Tenantfrom switch_core.db.runtime_role import grant_runtime_role-from switch_core.tenant_context import bind_tenant_id, unbind_tenant_id+from switch_core.tenant_context import tenant_scopeasync def _seed_tenant_zero(conn: AsyncConnection) -> None:@@ -85,19 +86,18 @@ async def session_factory(async with engine.begin() as conn:await conn.run_sync(Base.metadata.create_all)await _seed_tenant_zero(conn)- token = (- None+ ambient_tenant = (+ contextlib.nullcontext()if request.node.get_closest_marker("no_ambient_tenant")- else bind_tenant_id(TENANT_ZERO_ID)+ else tenant_scope(TENANT_ZERO_ID))try:- # Goes through the same factory constructor production wiring uses,- # so this fixture — which backs most of the store test suite — differs- # from production in as little as possible.- yield create_session_factory(engine)+ with ambient_tenant:+ # Goes through the same factory constructor production wiring+ # uses, so this fixture — which backs most of the store test+ # suite — differs from production in as little as possible.+ yield create_session_factory(engine)finally:- if token is not None:- unbind_tenant_id(token)async with engine.begin() as conn:await conn.run_sync(Base.metadata.drop_all)await engine.dispose()