@@ -435,8 +435,8 @@ async def test_load_toolset_success(self, tool_name, client):
435
435
assert "argB" in res
436
436
437
437
@pytest .mark .asyncio
438
- async def test_bind_param_success (self , tool_name , client ):
439
- """Tests 'bind_param ' with a bound parameter specified."""
438
+ async def test_bind_params_success (self , tool_name , client ):
439
+ """Tests 'bind_params ' with a bound parameter specified."""
440
440
tool = await client .load_tool (tool_name )
441
441
442
442
assert len (tool .__signature__ .parameters ) == 2
@@ -451,8 +451,8 @@ async def test_bind_param_success(self, tool_name, client):
451
451
assert "argA" in res
452
452
453
453
@pytest .mark .asyncio
454
- async def test_bind_callable_param_success (self , tool_name , client ):
455
- """Tests 'bind_param ' with a bound parameter specified."""
454
+ async def test_bind_callable_params_success (self , tool_name , client ):
455
+ """Tests 'bind_params ' with a bound parameter specified."""
456
456
tool = await client .load_tool (tool_name )
457
457
458
458
assert len (tool .__signature__ .parameters ) == 2
@@ -467,7 +467,7 @@ async def test_bind_callable_param_success(self, tool_name, client):
467
467
assert "argA" in res
468
468
469
469
@pytest .mark .asyncio
470
- async def test_bind_param_fail (self , tool_name , client ):
470
+ async def test_bind_params_fail (self , tool_name , client ):
471
471
"""Tests 'bind_params' with a bound parameter that doesn't exist."""
472
472
tool = await client .load_tool (tool_name )
473
473
@@ -479,7 +479,7 @@ async def test_bind_param_fail(self, tool_name, client):
479
479
assert "unable to bind parameters: no parameter named argC" in str (e .value )
480
480
481
481
@pytest .mark .asyncio
482
- async def test_rebind_param_fail (self , tool_name , client ):
482
+ async def test_rebind_params_fail (self , tool_name , client ):
483
483
"""
484
484
Tests that 'bind_params' fails when attempting to re-bind a
485
485
parameter that has already been bound.
@@ -502,7 +502,7 @@ async def test_rebind_param_fail(self, tool_name, client):
502
502
)
503
503
504
504
@pytest .mark .asyncio
505
- async def test_bind_param_static_value_success (self , tool_name , client ):
505
+ async def test_bind_params_static_value_success (self , tool_name , client ):
506
506
"""
507
507
Tests bind_params method with a static value.
508
508
"""
@@ -522,7 +522,7 @@ async def test_bind_param_static_value_success(self, tool_name, client):
522
522
assert res_payload == {"argA" : passed_value_a , "argB" : bound_value }
523
523
524
524
@pytest .mark .asyncio
525
- async def test_bind_param_sync_callable_value_success (self , tool_name , client ):
525
+ async def test_bind_params_sync_callable_value_success (self , tool_name , client ):
526
526
"""
527
527
Tests bind_params method with a sync callable value.
528
528
"""
@@ -544,7 +544,7 @@ async def test_bind_param_sync_callable_value_success(self, tool_name, client):
544
544
bound_sync_callable .assert_called_once ()
545
545
546
546
@pytest .mark .asyncio
547
- async def test_bind_param_async_callable_value_success (self , tool_name , client ):
547
+ async def test_bind_params_async_callable_value_success (self , tool_name , client ):
548
548
"""
549
549
Tests bind_params method with an async callable value.
550
550
"""
@@ -565,6 +565,137 @@ async def test_bind_param_async_callable_value_success(self, tool_name, client):
565
565
assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
566
566
bound_async_callable .assert_awaited_once ()
567
567
568
+ @pytest .mark .asyncio
569
+ async def test_bind_param_success (self , tool_name , client ):
570
+ """Tests 'bind_param' with a bound parameter specified."""
571
+ tool = await client .load_tool (tool_name )
572
+
573
+ assert len (tool .__signature__ .parameters ) == 2
574
+ assert "argA" in tool .__signature__ .parameters
575
+
576
+ tool = tool .bind_param ("argA" , 5 )
577
+
578
+ assert len (tool .__signature__ .parameters ) == 1
579
+ assert "argA" not in tool .__signature__ .parameters
580
+
581
+ res = await tool (True )
582
+ assert "argA" in res
583
+
584
+ @pytest .mark .asyncio
585
+ async def test_bind_callable_param_success (self , tool_name , client ):
586
+ """Tests 'bind_param' with a bound parameter specified."""
587
+ tool = await client .load_tool (tool_name )
588
+
589
+ assert len (tool .__signature__ .parameters ) == 2
590
+ assert "argA" in tool .__signature__ .parameters
591
+
592
+ tool = tool .bind_param ("argA" , lambda : 5 )
593
+
594
+ assert len (tool .__signature__ .parameters ) == 1
595
+ assert "argA" not in tool .__signature__ .parameters
596
+
597
+ res = await tool (True )
598
+ assert "argA" in res
599
+
600
+ @pytest .mark .asyncio
601
+ async def test_bind_param_fail (self , tool_name , client ):
602
+ """Tests 'bind_param' with a bound parameter that doesn't exist."""
603
+ tool = await client .load_tool (tool_name )
604
+
605
+ assert len (tool .__signature__ .parameters ) == 2
606
+ assert "argA" in tool .__signature__ .parameters
607
+
608
+ with pytest .raises (Exception ) as e :
609
+ tool .bind_param ("argC" , lambda : 5 )
610
+ assert "unable to bind parameters: no parameter named argC" in str (e .value )
611
+
612
+ @pytest .mark .asyncio
613
+ async def test_rebind_param_fail (self , tool_name , client ):
614
+ """
615
+ Tests that 'bind_param' fails when attempting to re-bind a
616
+ parameter that has already been bound.
617
+ """
618
+ tool = await client .load_tool (tool_name )
619
+
620
+ assert len (tool .__signature__ .parameters ) == 2
621
+ assert "argA" in tool .__signature__ .parameters
622
+
623
+ tool_with_bound_param = tool .bind_param ("argA" , lambda : 10 )
624
+
625
+ assert len (tool_with_bound_param .__signature__ .parameters ) == 1
626
+ assert "argA" not in tool_with_bound_param .__signature__ .parameters
627
+
628
+ with pytest .raises (ValueError ) as e :
629
+ tool_with_bound_param .bind_param ("argA" , lambda : 20 )
630
+
631
+ assert "cannot re-bind parameter: parameter 'argA' is already bound" in str (
632
+ e .value
633
+ )
634
+
635
+ @pytest .mark .asyncio
636
+ async def test_bind_param_static_value_success (self , tool_name , client ):
637
+ """
638
+ Tests bind_param method with a static value.
639
+ """
640
+
641
+ bound_value = "Test value"
642
+
643
+ tool = await client .load_tool (tool_name )
644
+ bound_tool = tool .bind_param ("argB" , bound_value )
645
+
646
+ assert bound_tool is not tool
647
+ assert "argB" not in bound_tool .__signature__ .parameters
648
+ assert "argA" in bound_tool .__signature__ .parameters
649
+
650
+ passed_value_a = 42
651
+ res_payload = await bound_tool (argA = passed_value_a )
652
+
653
+ assert res_payload == {"argA" : passed_value_a , "argB" : bound_value }
654
+
655
+ @pytest .mark .asyncio
656
+ async def test_bind_param_sync_callable_value_success (self , tool_name , client ):
657
+ """
658
+ Tests bind_param method with a sync callable value.
659
+ """
660
+
661
+ bound_value_result = True
662
+ bound_sync_callable = Mock (return_value = bound_value_result )
663
+
664
+ tool = await client .load_tool (tool_name )
665
+ bound_tool = tool .bind_param ("argB" , bound_sync_callable )
666
+
667
+ assert bound_tool is not tool
668
+ assert "argB" not in bound_tool .__signature__ .parameters
669
+ assert "argA" in bound_tool .__signature__ .parameters
670
+
671
+ passed_value_a = 42
672
+ res_payload = await bound_tool (argA = passed_value_a )
673
+
674
+ assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
675
+ bound_sync_callable .assert_called_once ()
676
+
677
+ @pytest .mark .asyncio
678
+ async def test_bind_param_async_callable_value_success (self , tool_name , client ):
679
+ """
680
+ Tests bind_param method with an async callable value.
681
+ """
682
+
683
+ bound_value_result = True
684
+ bound_async_callable = AsyncMock (return_value = bound_value_result )
685
+
686
+ tool = await client .load_tool (tool_name )
687
+ bound_tool = tool .bind_param ("argB" , bound_async_callable )
688
+
689
+ assert bound_tool is not tool
690
+ assert "argB" not in bound_tool .__signature__ .parameters
691
+ assert "argA" in bound_tool .__signature__ .parameters
692
+
693
+ passed_value_a = 42
694
+ res_payload = await bound_tool (argA = passed_value_a )
695
+
696
+ assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
697
+ bound_async_callable .assert_awaited_once ()
698
+
568
699
569
700
class TestUnusedParameterValidation :
570
701
"""
0 commit comments