Skip to content

Commit ce7068c

Browse files
committed
chore: Improve e2e tests for optional params around null values
1 parent 69a2776 commit ce7068c

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

packages/toolbox-core/tests/test_e2e.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ async def test_tool_signature_is_correct(self, toolbox: ToolboxClient):
250250
assert sig.parameters["id"].default is None
251251
assert sig.parameters["id"].annotation is Optional[int]
252252

253-
async def test_run_tool_with_optional_param_omitted(self, toolbox: ToolboxClient):
253+
async def test_run_tool_with_optional_params_omitted(self, toolbox: ToolboxClient):
254254
"""Invoke a tool providing only the required parameter."""
255255
tool = await toolbox.load_tool("search-rows")
256256

@@ -278,6 +278,21 @@ async def test_run_tool_with_optional_data_provided(self, toolbox: ToolboxClient
278278
assert "row5" not in response
279279
assert "row6" not in response
280280

281+
async def test_run_tool_with_optional_data_null(self, toolbox: ToolboxClient):
282+
"""Invoke a tool providing both required and optional parameters."""
283+
tool = await toolbox.load_tool("search-rows")
284+
285+
response = await tool(email="[email protected]", data=None)
286+
assert isinstance(response, str)
287+
assert 'email="[email protected]"' in response
288+
assert "row1" not in response
289+
assert "row2" in response
290+
assert "row3" not in response
291+
assert "row4" not in response
292+
assert "row5" not in response
293+
assert "row6" not in response
294+
295+
281296
async def test_run_tool_with_optional_id_provided(self, toolbox: ToolboxClient):
282297
"""Invoke a tool providing both required and optional parameters."""
283298
tool = await toolbox.load_tool("search-rows")
@@ -292,8 +307,28 @@ async def test_run_tool_with_optional_id_provided(self, toolbox: ToolboxClient):
292307
assert "row5" not in response
293308
assert "row6" not in response
294309

310+
async def test_run_tool_with_optional_id_null(self, toolbox: ToolboxClient):
311+
"""Invoke a tool providing both required and optional parameters."""
312+
tool = await toolbox.load_tool("search-rows")
313+
314+
response = await tool(email="[email protected]", id=None)
315+
assert isinstance(response, str)
316+
assert 'email="[email protected]"' in response
317+
assert "row1" not in response
318+
assert "row2" in response
319+
assert "row3" not in response
320+
assert "row4" not in response
321+
assert "row5" not in response
322+
assert "row6" not in response
323+
295324
async def test_run_tool_with_missing_required_param(self, toolbox: ToolboxClient):
296325
"""Invoke a tool without its required parameter."""
297326
tool = await toolbox.load_tool("search-rows")
298327
with pytest.raises(TypeError, match="missing a required argument: 'email'"):
299328
await tool(id=5, data="row5")
329+
330+
async def test_run_tool_with_required_param_null(self, toolbox: ToolboxClient):
331+
"""Invoke a tool without its required parameter."""
332+
tool = await toolbox.load_tool("search-rows")
333+
with pytest.raises(TypeError, match="missing a required argument: 'email'"):
334+
await tool(email=None, id=5, data="row5")

0 commit comments

Comments
 (0)