Skip to content

Commit ec1ce6b

Browse files
committed
chore: Fix unit test cases.
1 parent 04f293f commit ec1ce6b

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

packages/toolbox-core/tests/test_client.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,19 @@ async def test_bind_callable_param_success(self, tool_name, client):
430430
assert "argA" in res
431431

432432
@pytest.mark.asyncio
433-
async def test_bind_param_fail_on_rebind(self, tool_name, client):
433+
async def test_bind_param_fail(self, tool_name, client):
434+
"""Tests 'bind_parameters' with a bound parameter that doesn't exist."""
435+
tool = await client.load_tool(tool_name)
436+
437+
assert len(tool.__signature__.parameters) == 2
438+
assert "argA" in tool.__signature__.parameters
439+
440+
with pytest.raises(Exception) as e:
441+
tool.bind_parameters({"argC": lambda: 5})
442+
assert "unable to bind parameters: no parameter named argC" in str(e.value)
443+
444+
@pytest.mark.asyncio
445+
async def test_rebind_param_fail(self, tool_name, client):
434446
"""
435447
Tests that 'bind_parameters' fails when attempting to re-bind a
436448
parameter that has already been bound.
@@ -440,15 +452,12 @@ async def test_bind_param_fail_on_rebind(self, tool_name, client):
440452
assert len(tool.__signature__.parameters) == 2
441453
assert "argA" in tool.__signature__.parameters
442454

443-
bound_tool_once = tool.bind_parameters({"argA": 5})
444-
assert "argA" not in bound_tool_once.__signature__.parameters
445-
assert "argB" in bound_tool_once.__signature__.parameters
455+
tool_with_bound_param = tool.bind_parameters({"argA": lambda: 10})
446456

447-
expected_error_msg = (
448-
"cannot re-bind parameter: parameter 'argA' is already bound"
449-
)
450-
with pytest.raises(ValueError, match=expected_error_msg):
451-
bound_tool_once.bind_parameters({"argA": 10})
457+
with pytest.raises(ValueError) as e:
458+
tool_with_bound_param.bind_parameters({"argA": lambda: 20})
459+
460+
assert "cannot re-bind parameter: parameter 'argA' is already bound" in str(e.value)
452461

453462
@pytest.mark.asyncio
454463
async def test_bind_param_static_value_success(self, tool_name, client):

0 commit comments

Comments
 (0)