@@ -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
"""
@@ -566,6 +566,138 @@ async def test_bind_param_async_callable_value_success(self, tool_name, client):
566
566
bound_async_callable .assert_awaited_once ()
567
567
568
568
569
+ @pytest .mark .asyncio
570
+ async def test_bind_param_success (self , tool_name , client ):
571
+ """Tests 'bind_param' with a bound parameter specified."""
572
+ tool = await client .load_tool (tool_name )
573
+
574
+ assert len (tool .__signature__ .parameters ) == 2
575
+ assert "argA" in tool .__signature__ .parameters
576
+
577
+ tool = tool .bind_param ("argA" , 5 )
578
+
579
+ assert len (tool .__signature__ .parameters ) == 1
580
+ assert "argA" not in tool .__signature__ .parameters
581
+
582
+ res = await tool (True )
583
+ assert "argA" in res
584
+
585
+ @pytest .mark .asyncio
586
+ async def test_bind_callable_param_success (self , tool_name , client ):
587
+ """Tests 'bind_param' with a bound parameter specified."""
588
+ tool = await client .load_tool (tool_name )
589
+
590
+ assert len (tool .__signature__ .parameters ) == 2
591
+ assert "argA" in tool .__signature__ .parameters
592
+
593
+ tool = tool .bind_param ("argA" , lambda : 5 )
594
+
595
+ assert len (tool .__signature__ .parameters ) == 1
596
+ assert "argA" not in tool .__signature__ .parameters
597
+
598
+ res = await tool (True )
599
+ assert "argA" in res
600
+
601
+ @pytest .mark .asyncio
602
+ async def test_bind_param_fail (self , tool_name , client ):
603
+ """Tests 'bind_param' with a bound parameter that doesn't exist."""
604
+ tool = await client .load_tool (tool_name )
605
+
606
+ assert len (tool .__signature__ .parameters ) == 2
607
+ assert "argA" in tool .__signature__ .parameters
608
+
609
+ with pytest .raises (Exception ) as e :
610
+ tool .bind_param ("argC" , lambda : 5 )
611
+ assert "unable to bind parameters: no parameter named argC" in str (e .value )
612
+
613
+ @pytest .mark .asyncio
614
+ async def test_rebind_param_fail (self , tool_name , client ):
615
+ """
616
+ Tests that 'bind_param' fails when attempting to re-bind a
617
+ parameter that has already been bound.
618
+ """
619
+ tool = await client .load_tool (tool_name )
620
+
621
+ assert len (tool .__signature__ .parameters ) == 2
622
+ assert "argA" in tool .__signature__ .parameters
623
+
624
+ tool_with_bound_param = tool .bind_param ("argA" , lambda : 10 )
625
+
626
+ assert len (tool_with_bound_param .__signature__ .parameters ) == 1
627
+ assert "argA" not in tool_with_bound_param .__signature__ .parameters
628
+
629
+ with pytest .raises (ValueError ) as e :
630
+ tool_with_bound_param .bind_param ("argA" , lambda : 20 )
631
+
632
+ assert "cannot re-bind parameter: parameter 'argA' is already bound" in str (
633
+ e .value
634
+ )
635
+
636
+ @pytest .mark .asyncio
637
+ async def test_bind_param_static_value_success (self , tool_name , client ):
638
+ """
639
+ Tests bind_param method with a static value.
640
+ """
641
+
642
+ bound_value = "Test value"
643
+
644
+ tool = await client .load_tool (tool_name )
645
+ bound_tool = tool .bind_param ("argB" , bound_value )
646
+
647
+ assert bound_tool is not tool
648
+ assert "argB" not in bound_tool .__signature__ .parameters
649
+ assert "argA" in bound_tool .__signature__ .parameters
650
+
651
+ passed_value_a = 42
652
+ res_payload = await bound_tool (argA = passed_value_a )
653
+
654
+ assert res_payload == {"argA" : passed_value_a , "argB" : bound_value }
655
+
656
+ @pytest .mark .asyncio
657
+ async def test_bind_param_sync_callable_value_success (self , tool_name , client ):
658
+ """
659
+ Tests bind_param method with a sync callable value.
660
+ """
661
+
662
+ bound_value_result = True
663
+ bound_sync_callable = Mock (return_value = bound_value_result )
664
+
665
+ tool = await client .load_tool (tool_name )
666
+ bound_tool = tool .bind_param ("argB" , bound_sync_callable )
667
+
668
+ assert bound_tool is not tool
669
+ assert "argB" not in bound_tool .__signature__ .parameters
670
+ assert "argA" in bound_tool .__signature__ .parameters
671
+
672
+ passed_value_a = 42
673
+ res_payload = await bound_tool (argA = passed_value_a )
674
+
675
+ assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
676
+ bound_sync_callable .assert_called_once ()
677
+
678
+ @pytest .mark .asyncio
679
+ async def test_bind_param_async_callable_value_success (self , tool_name , client ):
680
+ """
681
+ Tests bind_param method with an async callable value.
682
+ """
683
+
684
+ bound_value_result = True
685
+ bound_async_callable = AsyncMock (return_value = bound_value_result )
686
+
687
+ tool = await client .load_tool (tool_name )
688
+ bound_tool = tool .bind_param ("argB" , bound_async_callable )
689
+
690
+ assert bound_tool is not tool
691
+ assert "argB" not in bound_tool .__signature__ .parameters
692
+ assert "argA" in bound_tool .__signature__ .parameters
693
+
694
+ passed_value_a = 42
695
+ res_payload = await bound_tool (argA = passed_value_a )
696
+
697
+ assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
698
+ bound_async_callable .assert_awaited_once ()
699
+
700
+
569
701
class TestUnusedParameterValidation :
570
702
"""
571
703
Tests for validation errors related to unused auth tokens or bound
0 commit comments