Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions packages/toolbox-langchain/tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,42 @@ async def get_n_rows_tool(self, toolbox):
return tool

#### Basic e2e tests
@pytest.mark.asyncio
@pytest.mark.parametrize(
"tool_name, params, expected_keys",
[
(
"process-list",
{"emails": ["user1@example.com", "user2@example.com"]},
["id", "email", "data"],
),
(
"handle-nested-config",
{"filter": {"email": "user1@example.com"}},
["id", "email", "data", "metadata"],
),
(
"manage-data-batches",
{"batches": {"group_a": [1, 2], "group_b": [3]}},
["id", "email", "data"],
),
(
"lookup-by-profile",
{"profile": {"identity": {"email": "user1@example.com"}, "display": {"label": "User One", "source": "crm"}}},
["id", "email", "data", "contact", "display_info"],
),
],
)
async def test_async_complex_param_tools(self, toolbox, tool_name, params, expected_keys):
tool = await toolbox.aload_tool(tool_name)
response = await tool.ainvoke(params)
if isinstance(response, list):
assert all(any(key in row for key in response) for row in expected_keys)
elif isinstance(response, dict):
assert any(key in response for key in expected_keys)
else:
assert response is not None

@pytest.mark.parametrize(
"toolset_name, expected_length, expected_tools",
[
Expand Down Expand Up @@ -204,6 +240,42 @@ def get_n_rows_tool(self, toolbox):
return tool

#### Basic e2e tests
@pytest.mark.parametrize(
"tool_name, params, expected_keys",
[
(
"process-list",
{"emails": ["user1@example.com", "user2@example.com"]},
["id", "email", "data"],
),
(
"handle-nested-config",
{"filter": {"email": "user1@example.com"}},
["id", "email", "data", "metadata"],
),
(
"manage-data-batches",
{"batches": {"group_a": [1, 2], "group_b": [3]}},
["id", "email", "data"],
),
(
"lookup-by-profile",
{"profile": {"identity": {"email": "user1@example.com"}, "display": {"label": "User One", "source": "crm"}}},
["id", "email", "data", "contact", "display_info"],
),
],
)

def test_sync_complex_param_tools(self, toolbox, tool_name, params, expected_keys):
tool = toolbox.load_tool(tool_name)
response = tool.invoke(params)
if isinstance(response, list):
assert all(any(key in row for key in expected_keys) for row in response)
elif isinstance(response, dict):
assert any(key in response for key in expected_keys)
else:
assert response is not None

@pytest.mark.parametrize(
"toolset_name, expected_length, expected_tools",
[
Expand Down
Loading