Skip to content

Commit 3ae0ad2

Browse files
committed
fix: Fix integration test
1 parent a586bea commit 3ae0ad2

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

packages/toolbox-langchain/tests/test_async_tools.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -304,46 +304,46 @@ async def test_toolbox_tool_call_with_auth_tokens(self, auth_toolbox_tool):
304304

305305
async def test_toolbox_tool_call_with_auth_tokens_insecure(
306306
self, auth_toolbox_tool, auth_tool_schema_dict
307-
): # Add auth_tool_schema_dict fixture
307+
):
308308
core_tool_of_auth_tool = auth_toolbox_tool._AsyncToolboxTool__core_tool
309309
mock_session = core_tool_of_auth_tool._ToolboxTool__session
310310

311-
# *** Fix: Use the injected fixture value auth_tool_schema_dict ***
312-
insecure_core_tool = self._create_core_tool_from_dict(
313-
session=mock_session,
314-
name="test_tool",
315-
schema_dict=auth_tool_schema_dict, # Use the fixture value here
316-
url="http://test-url",
317-
)
318-
insecure_auth_langchain_tool = AsyncToolboxTool(core_tool=insecure_core_tool)
319-
320311
with pytest.warns(
321312
UserWarning,
322313
match="Sending ID token over HTTP. User data may be exposed. Use HTTPS for secure communication.",
323314
):
324-
tool_with_getter = insecure_auth_langchain_tool.add_auth_token_getters(
325-
{"test-auth-source": lambda: "test-token"}
315+
insecure_core_tool = self._create_core_tool_from_dict(
316+
session=mock_session,
317+
name="test_tool",
318+
schema_dict=auth_tool_schema_dict,
319+
url="http://test-url",
326320
)
327-
result = await tool_with_getter.ainvoke({"param2": 123})
328-
assert result == "test-result"
329321

330-
modified_core_tool_in_new_tool = (
331-
tool_with_getter._AsyncToolboxTool__core_tool
332-
)
333-
assert (
334-
modified_core_tool_in_new_tool._ToolboxTool__base_url
335-
== "http://test-url"
336-
)
337-
assert (
338-
modified_core_tool_in_new_tool._ToolboxTool__url
339-
== "http://test-url/api/tool/test_tool/invoke"
340-
)
322+
insecure_auth_langchain_tool = AsyncToolboxTool(core_tool=insecure_core_tool)
341323

342-
modified_core_tool_in_new_tool._ToolboxTool__session.post.assert_called_once_with(
343-
"http://test-url/api/tool/test_tool/invoke",
344-
json={"param2": 123},
345-
headers={"test-auth-source_token": "test-token"},
346-
)
324+
tool_with_getter = insecure_auth_langchain_tool.add_auth_token_getters(
325+
{"test-auth-source": lambda: "test-token"}
326+
)
327+
result = await tool_with_getter.ainvoke({"param2": 123})
328+
assert result == "test-result"
329+
330+
modified_core_tool_in_new_tool = (
331+
tool_with_getter._AsyncToolboxTool__core_tool
332+
)
333+
assert (
334+
modified_core_tool_in_new_tool._ToolboxTool__base_url
335+
== "http://test-url"
336+
)
337+
assert (
338+
modified_core_tool_in_new_tool._ToolboxTool__url
339+
== "http://test-url/api/tool/test_tool/invoke"
340+
)
341+
342+
modified_core_tool_in_new_tool._ToolboxTool__session.post.assert_called_once_with(
343+
"http://test-url/api/tool/test_tool/invoke",
344+
json={"param2": 123},
345+
headers={"test-auth-source_token": "test-token"},
346+
)
347347

348348
async def test_toolbox_tool_call_with_invalid_input(self, toolbox_tool):
349349
with pytest.raises(ValidationError) as e:

0 commit comments

Comments
 (0)