Tests: keep auth and runtime files out of the real data directory.

Login bootstraps data/auth/mcp_token, so a full pytest run replaced the
running API's MCP token. Point every data/ path at the temp test state,
and pin single-session mode in the test that depends on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
oliver 2026-10-16 19:26:53 +08:00
parent a36de061cd
commit 918ece86c3
2 changed files with 14 additions and 1 deletions

View file

@ -190,10 +190,11 @@ class AuthApiTests(unittest.TestCase):
reuse = self.client.post("/v1/auth/refresh", json={"refresh_token": refresh})
self.assertEqual(reuse.status_code, 401)
@patch("netx_api.auth_service.settings.auth_single_session", True)
def test_single_session_login_revokes_others(self) -> None:
token = self._login()
token2 = self._login()
# Default auth_single_session=True: first login is kicked.
# Single-session mode: first login is kicked.
self.assertEqual(
self.client.get("/v1/probe", headers={"Authorization": f"Bearer {token}"}).status_code,
401,