@@ -131,7 +131,10 @@ def test_ask_question(genie, mock_workspace_client):
131131 ]
132132 )
133133
134- with patch .object (genie ._mcp_client , "call_tool" , return_value = mock_mcp_result ):
134+ mock_mcp_client = MagicMock ()
135+ mock_mcp_client .call_tool .return_value = mock_mcp_result
136+
137+ with patch .object (genie , "_get_mcp_client" , return_value = mock_mcp_client ):
135138 genie_result = genie .ask_question ("What is the meaning of life?" )
136139 assert genie_result .result == "Answer"
137140 assert genie_result .conversation_id == "123"
@@ -147,7 +150,10 @@ def test_ask_question_continued_conversation(genie, mock_workspace_client):
147150 ]
148151 )
149152
150- with patch .object (genie ._mcp_client , "call_tool" , return_value = mock_mcp_result ):
153+ mock_mcp_client = MagicMock ()
154+ mock_mcp_client .call_tool .return_value = mock_mcp_result
155+
156+ with patch .object (genie , "_get_mcp_client" , return_value = mock_mcp_client ):
151157 genie_result = genie .ask_question ("What is the meaning of life?" , "123" )
152158 assert genie_result .result == "42"
153159 assert genie_result .conversation_id == "123"
@@ -163,11 +169,14 @@ def test_ask_question_calls_mcp_without_conversation_id(genie, mock_workspace_cl
163169 ]
164170 )
165171
166- with patch .object (genie ._mcp_client , "call_tool" , return_value = mock_mcp_result ) as mock_call :
172+ mock_mcp_client = MagicMock ()
173+ mock_mcp_client .call_tool .return_value = mock_mcp_result
174+
175+ with patch .object (genie , "_get_mcp_client" , return_value = mock_mcp_client ):
167176 genie .ask_question ("What is the meaning of life?" )
168177
169178 # Verify MCP client was called with correct args (no conversation_id)
170- mock_call .assert_called_once_with (
179+ mock_mcp_client . call_tool .assert_called_once_with (
171180 "query_space_test_space_id" , {"query" : "What is the meaning of life?" }
172181 )
173182
@@ -183,11 +192,14 @@ def test_ask_question_calls_mcp_with_conversation_id(genie, mock_workspace_clien
183192 ]
184193 )
185194
186- with patch .object (genie ._mcp_client , "call_tool" , return_value = mock_mcp_result ) as mock_call :
195+ mock_mcp_client = MagicMock ()
196+ mock_mcp_client .call_tool .return_value = mock_mcp_result
197+
198+ with patch .object (genie , "_get_mcp_client" , return_value = mock_mcp_client ):
187199 genie .ask_question ("What is the meaning of life?" , "123" )
188200
189201 # Verify MCP client was called with conversation_id included
190- mock_call .assert_called_once_with (
202+ mock_mcp_client . call_tool .assert_called_once_with (
191203 "query_space_test_space_id" ,
192204 {"query" : "What is the meaning of life?" , "conversation_id" : "123" },
193205 )
0 commit comments