@@ -66,6 +66,7 @@ def test_tool_auth():
66
66
],
67
67
)
68
68
69
+
69
70
@pytest .fixture
70
71
def tool_schema_minimal ():
71
72
"""A tool with no parameters, no auth."""
@@ -74,14 +75,15 @@ def tool_schema_minimal():
74
75
parameters = [],
75
76
)
76
77
78
+
77
79
@pytest .fixture
78
80
def tool_schema_requires_auth_X ():
79
81
"""A tool requiring 'auth_service_X'."""
80
82
return ToolSchema (
81
83
description = "Tool Requiring Auth X" ,
82
84
parameters = [
83
85
ParameterSchema (
84
- name = "auth_param_X" , #
86
+ name = "auth_param_X" , #
85
87
type = "string" ,
86
88
description = "Auth X Token" ,
87
89
authSources = ["auth_service_X" ],
@@ -101,6 +103,7 @@ def tool_schema_with_param_P():
101
103
],
102
104
)
103
105
106
+
104
107
# --- Helper Functions for Mocking ---
105
108
106
109
@@ -580,7 +583,9 @@ async def test_load_tool_with_unused_auth_token_raises_error(
580
583
The tool (tool_schema_minimal) does not declare any authSources.
581
584
"""
582
585
tool_name = "minimal_tool_for_unused_auth"
583
- mock_tool_load (aioresponses , tool_name , tool_schema_minimal , base_url = TEST_BASE_URL )
586
+ mock_tool_load (
587
+ aioresponses , tool_name , tool_schema_minimal , base_url = TEST_BASE_URL
588
+ )
584
589
585
590
async with ToolboxClient (TEST_BASE_URL ) as client :
586
591
with pytest .raises (
@@ -601,7 +606,9 @@ async def test_load_tool_with_unused_bound_parameter_raises_error(
601
606
provided. The tool (tool_schema_minimal) has no parameters to bind.
602
607
"""
603
608
tool_name = "minimal_tool_for_unused_bound"
604
- mock_tool_load (aioresponses , tool_name , tool_schema_minimal , base_url = TEST_BASE_URL )
609
+ mock_tool_load (
610
+ aioresponses , tool_name , tool_schema_minimal , base_url = TEST_BASE_URL
611
+ )
605
612
606
613
async with ToolboxClient (TEST_BASE_URL ) as client :
607
614
with pytest .raises (
@@ -621,7 +628,9 @@ async def test_load_tool_with_unused_auth_and_bound_raises_error(
621
628
are provided.
622
629
"""
623
630
tool_name = "minimal_tool_for_unused_both"
624
- mock_tool_load (aioresponses , tool_name , tool_schema_minimal , base_url = TEST_BASE_URL )
631
+ mock_tool_load (
632
+ aioresponses , tool_name , tool_schema_minimal , base_url = TEST_BASE_URL
633
+ )
625
634
626
635
async with ToolboxClient (TEST_BASE_URL ) as client :
627
636
with pytest .raises (
@@ -647,7 +656,9 @@ async def test_load_toolset_strict_one_tool_unused_auth_raises(
647
656
toolset_name = "strict_set_single_tool_unused_auth"
648
657
tool_A_name = "tool_A_minimal"
649
658
tools_dict = {tool_A_name : tool_schema_minimal }
650
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
659
+ mock_toolset_load (
660
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
661
+ )
651
662
652
663
async with ToolboxClient (TEST_BASE_URL ) as client :
653
664
with pytest .raises (
@@ -677,7 +688,9 @@ async def test_load_toolset_strict_first_tool_fails_auth_raises(
677
688
tool_minimal_name : tool_schema_minimal ,
678
689
tool_auth_X_name : tool_schema_requires_auth_X ,
679
690
}
680
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
691
+ mock_toolset_load (
692
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
693
+ )
681
694
682
695
async with ToolboxClient (TEST_BASE_URL ) as client :
683
696
with pytest .raises (
@@ -708,7 +721,9 @@ async def test_load_toolset_strict_second_tool_fails_auth_raises(
708
721
tool_auth_X_name : tool_schema_requires_auth_X ,
709
722
tool_minimal_name : tool_schema_minimal ,
710
723
}
711
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
724
+ mock_toolset_load (
725
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
726
+ )
712
727
713
728
async with ToolboxClient (TEST_BASE_URL ) as client :
714
729
with pytest .raises (
@@ -722,6 +737,7 @@ async def test_load_toolset_strict_second_tool_fails_auth_raises(
722
737
},
723
738
strict = True ,
724
739
)
740
+
725
741
@pytest .mark .asyncio
726
742
async def test_load_toolset_strict_one_tool_unused_bound_raises (
727
743
self , aioresponses , tool_schema_minimal
@@ -733,7 +749,9 @@ async def test_load_toolset_strict_one_tool_unused_bound_raises(
733
749
toolset_name = "strict_set_single_tool_unused_bound"
734
750
tool_A_name = "tool_A_minimal_for_bound"
735
751
tools_dict = {tool_A_name : tool_schema_minimal }
736
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
752
+ mock_toolset_load (
753
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
754
+ )
737
755
738
756
async with ToolboxClient (TEST_BASE_URL ) as client :
739
757
with pytest .raises (
@@ -762,7 +780,9 @@ async def test_load_toolset_strict_first_tool_fails_bound_raises(
762
780
tool_minimal_name : tool_schema_minimal ,
763
781
tool_param_P_name : tool_schema_with_param_P ,
764
782
}
765
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
783
+ mock_toolset_load (
784
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
785
+ )
766
786
767
787
async with ToolboxClient (TEST_BASE_URL ) as client :
768
788
with pytest .raises (
@@ -793,7 +813,9 @@ async def test_load_toolset_strict_second_tool_fails_bound_raises(
793
813
tool_param_P_name : tool_schema_with_param_P ,
794
814
tool_minimal_name : tool_schema_minimal ,
795
815
}
796
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
816
+ mock_toolset_load (
817
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
818
+ )
797
819
798
820
async with ToolboxClient (TEST_BASE_URL ) as client :
799
821
with pytest .raises (
@@ -808,8 +830,6 @@ async def test_load_toolset_strict_second_tool_fails_bound_raises(
808
830
strict = True ,
809
831
)
810
832
811
-
812
-
813
833
@pytest .mark .asyncio
814
834
async def test_load_toolset_strict_with_unused_auth_and_bound_raises_error (
815
835
self , aioresponses , tool_schema_minimal
@@ -822,7 +842,9 @@ async def test_load_toolset_strict_with_unused_auth_and_bound_raises_error(
822
842
toolset_name = "strict_set_unused_both_minimal_tool"
823
843
tool_minimal_name = "minimal_for_both_strict"
824
844
tools_dict = {tool_minimal_name : tool_schema_minimal }
825
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
845
+ mock_toolset_load (
846
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
847
+ )
826
848
827
849
async with ToolboxClient (TEST_BASE_URL ) as client :
828
850
with pytest .raises (
@@ -851,7 +873,9 @@ async def test_load_toolset_non_strict_globally_unused_auth_raises_error(
851
873
"auth_tool" : tool_schema_requires_auth_X ,
852
874
"minimal_tool_in_set" : tool_schema_minimal ,
853
875
}
854
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
876
+ mock_toolset_load (
877
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
878
+ )
855
879
856
880
async with ToolboxClient (TEST_BASE_URL ) as client :
857
881
with pytest .raises (
@@ -880,7 +904,9 @@ async def test_load_toolset_non_strict_globally_unused_bound_raises_error(
880
904
"param_P_tool_in_set" : tool_schema_with_param_P ,
881
905
"minimal_tool_in_set_bound" : tool_schema_minimal ,
882
906
}
883
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
907
+ mock_toolset_load (
908
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
909
+ )
884
910
885
911
async with ToolboxClient (TEST_BASE_URL ) as client :
886
912
with pytest .raises (
@@ -909,7 +935,9 @@ async def test_load_toolset_non_strict_globally_unused_auth_and_bound_raises_err
909
935
"auth_tool_for_both" : tool_schema_requires_auth_X ,
910
936
"param_P_tool_for_both" : tool_schema_with_param_P ,
911
937
}
912
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
938
+ mock_toolset_load (
939
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
940
+ )
913
941
914
942
async with ToolboxClient (TEST_BASE_URL ) as client :
915
943
with pytest .raises (
@@ -928,7 +956,7 @@ async def test_load_toolset_non_strict_globally_unused_auth_and_bound_raises_err
928
956
},
929
957
strict = False ,
930
958
)
931
-
959
+
932
960
@pytest .mark .asyncio
933
961
async def test_load_toolset_non_strict_default_name_globally_unused_auth (
934
962
self , aioresponses , tool_schema_minimal
@@ -940,7 +968,9 @@ async def test_load_toolset_non_strict_default_name_globally_unused_auth(
940
968
toolset_name = None
941
969
expected_error_toolset_name = "default"
942
970
tools_dict = {"some_minimal_tool" : tool_schema_minimal }
943
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
971
+ mock_toolset_load (
972
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
973
+ )
944
974
945
975
async with ToolboxClient (TEST_BASE_URL ) as client :
946
976
with pytest .raises (
@@ -949,11 +979,12 @@ async def test_load_toolset_non_strict_default_name_globally_unused_auth(
949
979
):
950
980
await client .load_toolset (
951
981
name = toolset_name ,
952
- auth_token_getters = {"globally_unused_auth_default" : lambda : "token" },
982
+ auth_token_getters = {
983
+ "globally_unused_auth_default" : lambda : "token"
984
+ },
953
985
strict = False ,
954
986
)
955
987
956
-
957
988
@pytest .mark .asyncio
958
989
async def test_load_toolset_non_strict_partially_used_auth_succeeds (
959
990
self , aioresponses , tool_schema_minimal , tool_schema_requires_auth_X
@@ -967,7 +998,9 @@ async def test_load_toolset_non_strict_partially_used_auth_succeeds(
967
998
"auth_tool_partial" : tool_schema_requires_auth_X ,
968
999
"minimal_tool_partial" : tool_schema_minimal ,
969
1000
}
970
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
1001
+ mock_toolset_load (
1002
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
1003
+ )
971
1004
972
1005
async with ToolboxClient (TEST_BASE_URL ) as client :
973
1006
await client .load_toolset (
@@ -976,7 +1009,6 @@ async def test_load_toolset_non_strict_partially_used_auth_succeeds(
976
1009
strict = False ,
977
1010
)
978
1011
979
-
980
1012
@pytest .mark .asyncio
981
1013
async def test_load_toolset_non_strict_partially_used_bound_succeeds (
982
1014
self , aioresponses , tool_schema_minimal , tool_schema_with_param_P
@@ -990,7 +1022,9 @@ async def test_load_toolset_non_strict_partially_used_bound_succeeds(
990
1022
"param_P_tool_partial" : tool_schema_with_param_P ,
991
1023
"minimal_tool_partial_bound" : tool_schema_minimal ,
992
1024
}
993
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
1025
+ mock_toolset_load (
1026
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
1027
+ )
994
1028
995
1029
async with ToolboxClient (TEST_BASE_URL ) as client :
996
1030
await client .load_toolset (
@@ -999,7 +1033,6 @@ async def test_load_toolset_non_strict_partially_used_bound_succeeds(
999
1033
strict = False ,
1000
1034
)
1001
1035
1002
-
1003
1036
@pytest .mark .asyncio
1004
1037
async def test_load_toolset_non_strict_partially_used_auth_and_bound_succeeds (
1005
1038
self , aioresponses , tool_schema_requires_auth_X , tool_schema_with_param_P
@@ -1013,7 +1046,9 @@ async def test_load_toolset_non_strict_partially_used_auth_and_bound_succeeds(
1013
1046
"auth_tool_for_both" : tool_schema_requires_auth_X ,
1014
1047
"param_P_tool_for_both" : tool_schema_with_param_P ,
1015
1048
}
1016
- mock_toolset_load (aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL )
1049
+ mock_toolset_load (
1050
+ aioresponses , toolset_name , tools_dict , base_url = TEST_BASE_URL
1051
+ )
1017
1052
1018
1053
async with ToolboxClient (TEST_BASE_URL ) as client :
1019
1054
await client .load_toolset (
0 commit comments