Skip to content

Commit 197f0bd

Browse files
committed
Handled upgraded genai library
1 parent b6a7b81 commit 197f0bd

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

template/{{agent_app_name}}/tests/test_mcp_templates/test_mcp_crewai.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class TestMyAgentMCPIntegration:
175175
assert len(writer.tools) == 1 # 1 MCP tool
176176
assert len(editor.tools) == 1 # 1 MCP tool
177177

178-
@patch("datarobot_genai.crewai.base.mcp_tools_context")
178+
@patch("datarobot_genai.crewai.base.mcp_tools_context", autospec=True)
179179
def test_agent_works_without_mcp_tools(
180180
self, mock_mcp_tools_context, crewai_common_mocks
181181
):
@@ -232,7 +232,7 @@ class TestMyAgentMCPIntegration:
232232

233233
assert access_count["count"] >= 3
234234

235-
@patch("datarobot_genai.crewai.base.mcp_tools_context")
235+
@patch("datarobot_genai.crewai.base.mcp_tools_context", autospec=True)
236236
def test_mcp_tool_execution_makes_request_to_server(
237237
self, mock_mcp_tools_context, crewai_common_mocks
238238
):

template/{{agent_app_name}}/tests/test_mcp_templates/test_mcp_langgraph.j2

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def langgraph_common_mocks():
7171
mock_execution_graph.astream.side_effect = _create_mock_astream()
7272

7373
with (
74-
patch("datarobot_genai.langgraph.agent.mcp_tools_context") as mock_mcp_context,
74+
patch(
75+
"datarobot_genai.langgraph.agent.mcp_tools_context",
76+
autospec=True,
77+
) as mock_mcp_context,
7578
patch.object(
7679
MyAgent,
7780
"workflow",
@@ -120,7 +123,8 @@ class TestMyAgentLangGraphMCPIntegration:
120123
except (StopIteration, AttributeError, TypeError, ValueError):
121124
pass
122125

123-
mock_context.assert_called_once_with(authorization_context={})
126+
mock_context.assert_called_once()
127+
assert mock_context.call_args.kwargs.get("authorization_context") == {}
124128
assert agent.mcp_tools == mock_tools
125129

126130
def test_agent_loads_mcp_tools_from_datarobot_deployment_in_invoke(
@@ -155,7 +159,8 @@ class TestMyAgentLangGraphMCPIntegration:
155159
except (StopIteration, AttributeError, TypeError, ValueError):
156160
pass
157161

158-
mock_context.assert_called_once_with(authorization_context={})
162+
mock_context.assert_called_once()
163+
assert mock_context.call_args.kwargs.get("authorization_context") == {}
159164
assert agent.mcp_tools == mock_tools
160165

161166
def test_agent_works_without_mcp_tools(self, langgraph_common_mocks):

template/{{agent_app_name}}/tests/test_mcp_templates/test_mcp_llamaindex.j2

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ class TestMyAgentMCPIntegration:
110110
# Expected when workflow is mocked
111111
pass
112112

113-
# Verify load_mcp_tools was called with correct parameters
114-
mock_load_mcp_tools.assert_called_once_with(authorization_context={})
113+
# Verify load_mcp_tools was called and provided authorization_context
114+
mock_load_mcp_tools.assert_called_once()
115+
assert (
116+
mock_load_mcp_tools.call_args.kwargs.get("authorization_context")
117+
== {}
118+
)
115119

116120
# Verify set_mcp_tools was called with the tools from MCP server
117121
assert agent.mcp_tools == mock_tools
@@ -164,8 +168,12 @@ class TestMyAgentMCPIntegration:
164168
# Expected when workflow is mocked
165169
pass
166170

167-
# Verify load_mcp_tools was called with correct parameters
168-
mock_load_mcp_tools.assert_called_once_with(authorization_context={})
171+
# Verify load_mcp_tools was called and provided authorization_context
172+
mock_load_mcp_tools.assert_called_once()
173+
assert (
174+
mock_load_mcp_tools.call_args.kwargs.get("authorization_context")
175+
== {}
176+
)
169177

170178
# Verify set_mcp_tools was called with the tools from MCP server
171179
assert agent.mcp_tools == mock_tools

0 commit comments

Comments
 (0)