From 7d8fc731d4e283691ee5ed2a5dffd23c1d287068 Mon Sep 17 00:00:00 2001 From: haosenwang1018 Date: Fri, 13 Mar 2026 05:59:34 +0000 Subject: [PATCH] test: cover python session workspace and destroy APIs --- python/test_client.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/python/test_client.py b/python/test_client.py index 62ae7b188..7667f9357 100644 --- a/python/test_client.py +++ b/python/test_client.py @@ -480,3 +480,44 @@ async def mock_request(method, params): assert captured["session.model.switchTo"]["modelId"] == "gpt-4.1" finally: await client.force_stop() + + @pytest.mark.asyncio + async def test_create_session_exposes_workspace_path(self): + client = CopilotClient({"cli_path": CLI_PATH}) + await client.start() + + try: + session = await client.create_session( + {"on_permission_request": PermissionHandler.approve_all} + ) + assert session.workspace_path is not None + assert session.workspace_path.endswith(session.session_id) + finally: + await client.force_stop() + + @pytest.mark.asyncio + async def test_destroy_warns_and_disconnects_session(self): + client = CopilotClient({"cli_path": CLI_PATH}) + await client.start() + + try: + session = await client.create_session( + {"on_permission_request": PermissionHandler.approve_all} + ) + + captured = {} + original_request = client._client.request + + async def mock_request(method, params): + captured[method] = params + if method == "session.destroy": + return {} + return await original_request(method, params) + + client._client.request = mock_request + with pytest.deprecated_call(match=r"destroy\(\) is deprecated, use disconnect\(\) instead"): + await session.destroy() + + assert captured["session.destroy"] == {"sessionId": session.session_id} + finally: + await client.force_stop()