11import json
22import uuid
3+ from unittest .mock import MagicMock
34
45from temporalio import activity
56from temporalio .client import Client
@@ -27,7 +28,9 @@ def _make_function_call_response(
2728 )
2829
2930
30- async def test_chatbot_save_note (client : Client , env : WorkflowEnvironment ):
31+ async def test_chatbot_save_note (
32+ client : Client , env : WorkflowEnvironment , mock_ls_client : MagicMock
33+ ):
3134 """Test save_note tool call loop — save_note runs as a workflow method."""
3235 call_count = 0
3336
@@ -47,7 +50,7 @@ async def mock_call_openai(request: OpenAIRequest) -> ChatResponse:
4750 task_queue = "test-langsmith-chatbot" ,
4851 workflows = [ChatbotWorkflow ],
4952 activities = [mock_call_openai ],
50- plugins = [LangSmithPlugin ()],
53+ plugins = [LangSmithPlugin (client = mock_ls_client )],
5154 ):
5255 wf_handle = await client .start_workflow (
5356 ChatbotWorkflow .run ,
@@ -68,8 +71,10 @@ async def mock_call_openai(request: OpenAIRequest) -> ChatResponse:
6871 assert result == "Session ended."
6972
7073
71- async def test_chatbot_read_note (client : Client , env : WorkflowEnvironment ):
72- """Test read_note tool call loop — read_note runs as a workflow method."""
74+ async def test_chatbot_read_note (
75+ client : Client , env : WorkflowEnvironment , mock_ls_client : MagicMock
76+ ):
77+ """Test read_note tool call loop — saves a note first, then reads it back."""
7378 call_count = 0
7479
7580 @activity .defn (name = "call_openai" )
@@ -97,7 +102,7 @@ async def mock_call_openai(request: OpenAIRequest) -> ChatResponse:
97102 task_queue = "test-langsmith-chatbot-read" ,
98103 workflows = [ChatbotWorkflow ],
99104 activities = [mock_call_openai ],
100- plugins = [LangSmithPlugin ()],
105+ plugins = [LangSmithPlugin (client = mock_ls_client )],
101106 ):
102107 wf_handle = await client .start_workflow (
103108 ChatbotWorkflow .run ,
0 commit comments