@@ -698,268 +698,6 @@ async def test_bind_param_async_callable_value_success(self, tool_name, client):
698
698
assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
699
699
bound_async_callable .assert_awaited_once ()
700
700
701
- @pytest .mark .asyncio
702
- async def test_bind_param_success (self , tool_name , client ):
703
- """Tests 'bind_param' with a bound parameter specified."""
704
- tool = await client .load_tool (tool_name )
705
-
706
- assert len (tool .__signature__ .parameters ) == 2
707
- assert "argA" in tool .__signature__ .parameters
708
-
709
- tool = tool .bind_param ("argA" , 5 )
710
-
711
- assert len (tool .__signature__ .parameters ) == 1
712
- assert "argA" not in tool .__signature__ .parameters
713
-
714
- res = await tool (True )
715
- assert "argA" in res
716
-
717
- @pytest .mark .asyncio
718
- async def test_bind_callable_param_success (self , tool_name , client ):
719
- """Tests 'bind_param' with a bound parameter specified."""
720
- tool = await client .load_tool (tool_name )
721
-
722
- assert len (tool .__signature__ .parameters ) == 2
723
- assert "argA" in tool .__signature__ .parameters
724
-
725
- tool = tool .bind_param ("argA" , lambda : 5 )
726
-
727
- assert len (tool .__signature__ .parameters ) == 1
728
- assert "argA" not in tool .__signature__ .parameters
729
-
730
- res = await tool (True )
731
- assert "argA" in res
732
-
733
- @pytest .mark .asyncio
734
- async def test_bind_param_fail (self , tool_name , client ):
735
- """Tests 'bind_param' with a bound parameter that doesn't exist."""
736
- tool = await client .load_tool (tool_name )
737
-
738
- assert len (tool .__signature__ .parameters ) == 2
739
- assert "argA" in tool .__signature__ .parameters
740
-
741
- with pytest .raises (Exception ) as e :
742
- tool .bind_param ("argC" , lambda : 5 )
743
- assert "unable to bind parameters: no parameter named argC" in str (e .value )
744
-
745
- @pytest .mark .asyncio
746
- async def test_rebind_param_fail (self , tool_name , client ):
747
- """
748
- Tests that 'bind_param' fails when attempting to re-bind a
749
- parameter that has already been bound.
750
- """
751
- tool = await client .load_tool (tool_name )
752
-
753
- assert len (tool .__signature__ .parameters ) == 2
754
- assert "argA" in tool .__signature__ .parameters
755
-
756
- tool_with_bound_param = tool .bind_param ("argA" , lambda : 10 )
757
-
758
- assert len (tool_with_bound_param .__signature__ .parameters ) == 1
759
- assert "argA" not in tool_with_bound_param .__signature__ .parameters
760
-
761
- with pytest .raises (ValueError ) as e :
762
- tool_with_bound_param .bind_param ("argA" , lambda : 20 )
763
-
764
- assert "cannot re-bind parameter: parameter 'argA' is already bound" in str (
765
- e .value
766
- )
767
-
768
- @pytest .mark .asyncio
769
- async def test_bind_param_static_value_success (self , tool_name , client ):
770
- """
771
- Tests bind_param method with a static value.
772
- """
773
-
774
- bound_value = "Test value"
775
-
776
- tool = await client .load_tool (tool_name )
777
- bound_tool = tool .bind_param ("argB" , bound_value )
778
-
779
- assert bound_tool is not tool
780
- assert "argB" not in bound_tool .__signature__ .parameters
781
- assert "argA" in bound_tool .__signature__ .parameters
782
-
783
- passed_value_a = 42
784
- res_payload = await bound_tool (argA = passed_value_a )
785
-
786
- assert res_payload == {"argA" : passed_value_a , "argB" : bound_value }
787
-
788
- @pytest .mark .asyncio
789
- async def test_bind_param_sync_callable_value_success (self , tool_name , client ):
790
- """
791
- Tests bind_param method with a sync callable value.
792
- """
793
-
794
- bound_value_result = True
795
- bound_sync_callable = Mock (return_value = bound_value_result )
796
-
797
- tool = await client .load_tool (tool_name )
798
- bound_tool = tool .bind_param ("argB" , bound_sync_callable )
799
-
800
- assert bound_tool is not tool
801
- assert "argB" not in bound_tool .__signature__ .parameters
802
- assert "argA" in bound_tool .__signature__ .parameters
803
-
804
- passed_value_a = 42
805
- res_payload = await bound_tool (argA = passed_value_a )
806
-
807
- assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
808
- bound_sync_callable .assert_called_once ()
809
-
810
- @pytest .mark .asyncio
811
- async def test_bind_param_async_callable_value_success (self , tool_name , client ):
812
- """
813
- Tests bind_param method with an async callable value.
814
- """
815
-
816
- bound_value_result = True
817
- bound_async_callable = AsyncMock (return_value = bound_value_result )
818
-
819
- tool = await client .load_tool (tool_name )
820
- bound_tool = tool .bind_param ("argB" , bound_async_callable )
821
-
822
- assert bound_tool is not tool
823
- assert "argB" not in bound_tool .__signature__ .parameters
824
- assert "argA" in bound_tool .__signature__ .parameters
825
-
826
- passed_value_a = 42
827
- res_payload = await bound_tool (argA = passed_value_a )
828
-
829
- assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
830
- bound_async_callable .assert_awaited_once ()
831
-
832
- @pytest .mark .asyncio
833
- async def test_bind_param_success (self , tool_name , client ):
834
- """Tests 'bind_param' with a bound parameter specified."""
835
- tool = await client .load_tool (tool_name )
836
-
837
- assert len (tool .__signature__ .parameters ) == 2
838
- assert "argA" in tool .__signature__ .parameters
839
-
840
- tool = tool .bind_param ("argA" , 5 )
841
-
842
- assert len (tool .__signature__ .parameters ) == 1
843
- assert "argA" not in tool .__signature__ .parameters
844
-
845
- res = await tool (True )
846
- assert "argA" in res
847
-
848
- @pytest .mark .asyncio
849
- async def test_bind_callable_param_success (self , tool_name , client ):
850
- """Tests 'bind_param' with a bound parameter specified."""
851
- tool = await client .load_tool (tool_name )
852
-
853
- assert len (tool .__signature__ .parameters ) == 2
854
- assert "argA" in tool .__signature__ .parameters
855
-
856
- tool = tool .bind_param ("argA" , lambda : 5 )
857
-
858
- assert len (tool .__signature__ .parameters ) == 1
859
- assert "argA" not in tool .__signature__ .parameters
860
-
861
- res = await tool (True )
862
- assert "argA" in res
863
-
864
- @pytest .mark .asyncio
865
- async def test_bind_param_fail (self , tool_name , client ):
866
- """Tests 'bind_param' with a bound parameter that doesn't exist."""
867
- tool = await client .load_tool (tool_name )
868
-
869
- assert len (tool .__signature__ .parameters ) == 2
870
- assert "argA" in tool .__signature__ .parameters
871
-
872
- with pytest .raises (Exception ) as e :
873
- tool .bind_param ("argC" , lambda : 5 )
874
- assert "unable to bind parameters: no parameter named argC" in str (e .value )
875
-
876
- @pytest .mark .asyncio
877
- async def test_rebind_param_fail (self , tool_name , client ):
878
- """
879
- Tests that 'bind_param' fails when attempting to re-bind a
880
- parameter that has already been bound.
881
- """
882
- tool = await client .load_tool (tool_name )
883
-
884
- assert len (tool .__signature__ .parameters ) == 2
885
- assert "argA" in tool .__signature__ .parameters
886
-
887
- tool_with_bound_param = tool .bind_param ("argA" , lambda : 10 )
888
-
889
- assert len (tool_with_bound_param .__signature__ .parameters ) == 1
890
- assert "argA" not in tool_with_bound_param .__signature__ .parameters
891
-
892
- with pytest .raises (ValueError ) as e :
893
- tool_with_bound_param .bind_param ("argA" , lambda : 20 )
894
-
895
- assert "cannot re-bind parameter: parameter 'argA' is already bound" in str (
896
- e .value
897
- )
898
-
899
- @pytest .mark .asyncio
900
- async def test_bind_param_static_value_success (self , tool_name , client ):
901
- """
902
- Tests bind_param method with a static value.
903
- """
904
-
905
- bound_value = "Test value"
906
-
907
- tool = await client .load_tool (tool_name )
908
- bound_tool = tool .bind_param ("argB" , bound_value )
909
-
910
- assert bound_tool is not tool
911
- assert "argB" not in bound_tool .__signature__ .parameters
912
- assert "argA" in bound_tool .__signature__ .parameters
913
-
914
- passed_value_a = 42
915
- res_payload = await bound_tool (argA = passed_value_a )
916
-
917
- assert res_payload == {"argA" : passed_value_a , "argB" : bound_value }
918
-
919
- @pytest .mark .asyncio
920
- async def test_bind_param_sync_callable_value_success (self , tool_name , client ):
921
- """
922
- Tests bind_param method with a sync callable value.
923
- """
924
-
925
- bound_value_result = True
926
- bound_sync_callable = Mock (return_value = bound_value_result )
927
-
928
- tool = await client .load_tool (tool_name )
929
- bound_tool = tool .bind_param ("argB" , bound_sync_callable )
930
-
931
- assert bound_tool is not tool
932
- assert "argB" not in bound_tool .__signature__ .parameters
933
- assert "argA" in bound_tool .__signature__ .parameters
934
-
935
- passed_value_a = 42
936
- res_payload = await bound_tool (argA = passed_value_a )
937
-
938
- assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
939
- bound_sync_callable .assert_called_once ()
940
-
941
- @pytest .mark .asyncio
942
- async def test_bind_param_async_callable_value_success (self , tool_name , client ):
943
- """
944
- Tests bind_param method with an async callable value.
945
- """
946
-
947
- bound_value_result = True
948
- bound_async_callable = AsyncMock (return_value = bound_value_result )
949
-
950
- tool = await client .load_tool (tool_name )
951
- bound_tool = tool .bind_param ("argB" , bound_async_callable )
952
-
953
- assert bound_tool is not tool
954
- assert "argB" not in bound_tool .__signature__ .parameters
955
- assert "argA" in bound_tool .__signature__ .parameters
956
-
957
- passed_value_a = 42
958
- res_payload = await bound_tool (argA = passed_value_a )
959
-
960
- assert res_payload == {"argA" : passed_value_a , "argB" : bound_value_result }
961
- bound_async_callable .assert_awaited_once ()
962
-
963
701
964
702
class TestUnusedParameterValidation :
965
703
"""
0 commit comments