@@ -131,6 +131,12 @@ def mock_core_tool(self, tool_schema_dict):
131
131
)
132
132
sync_mock .bind_params = Mock (return_value = new_mock_instance_for_methods )
133
133
134
+ sync_mock ._bound_params = {"mock_bound_param" : "mock_bound_value" }
135
+ sync_mock ._required_authn_params = {"mock_auth_source" : ["mock_param" ]}
136
+ sync_mock ._required_authz_tokens = ["mock_authz_token" ]
137
+ sync_mock ._auth_service_token_getters = {"mock_service" : lambda : "mock_token" }
138
+ sync_mock ._client_headers = {"mock_header" : "mock_header_value" }
139
+
134
140
return sync_mock
135
141
136
142
@pytest .fixture
@@ -166,6 +172,13 @@ def mock_core_sync_auth_tool(self, auth_tool_schema_dict):
166
172
return_value = new_mock_instance_for_methods
167
173
)
168
174
sync_mock .bind_params = Mock (return_value = new_mock_instance_for_methods )
175
+
176
+ sync_mock ._bound_params = {"mock_bound_param" : "mock_bound_value" }
177
+ sync_mock ._required_authn_params = {"mock_auth_source" : ["mock_param" ]}
178
+ sync_mock ._required_authz_tokens = ["mock_authz_token" ]
179
+ sync_mock ._auth_service_token_getters = {"mock_service" : lambda : "mock_token" }
180
+ sync_mock ._client_headers = {"mock_header" : "mock_header_value" }
181
+
169
182
return sync_mock
170
183
171
184
@pytest .fixture
@@ -303,3 +316,48 @@ async def to_thread_side_effect(func, *args, **kwargs_for_func):
303
316
304
317
assert mock_core_tool .call_count == 1
305
318
assert mock_core_tool .call_args == call (** kwargs_to_run )
319
+
320
+ def test_toolbox_tool_properties (self , toolbox_tool , mock_core_tool ):
321
+ """Tests that the properties correctly proxy to the core tool."""
322
+ assert toolbox_tool ._bound_params == mock_core_tool ._bound_params
323
+ assert (
324
+ toolbox_tool ._required_authn_params == mock_core_tool ._required_authn_params
325
+ )
326
+ assert (
327
+ toolbox_tool ._required_authz_tokens == mock_core_tool ._required_authz_tokens
328
+ )
329
+ assert (
330
+ toolbox_tool ._auth_service_token_getters
331
+ == mock_core_tool ._auth_service_token_getters
332
+ )
333
+ assert toolbox_tool ._client_headers == mock_core_tool ._client_headers
334
+
335
+ def test_toolbox_tool_add_auth_tokens_deprecated (
336
+ self , auth_toolbox_tool , mock_core_sync_auth_tool
337
+ ):
338
+ """Tests the deprecated add_auth_tokens method."""
339
+ auth_tokens = {"test-auth-source" : lambda : "test-token" }
340
+ with pytest .warns (DeprecationWarning ):
341
+ new_tool = auth_toolbox_tool .add_auth_tokens (auth_tokens )
342
+
343
+ # Check that the call was correctly forwarded to the new method on the core tool
344
+ mock_core_sync_auth_tool .add_auth_token_getters .assert_called_once_with (
345
+ auth_tokens
346
+ )
347
+ assert isinstance (new_tool , ToolboxTool )
348
+
349
+ def test_toolbox_tool_add_auth_token_deprecated (
350
+ self , auth_toolbox_tool , mock_core_sync_auth_tool
351
+ ):
352
+ """Tests the deprecated add_auth_token method."""
353
+ get_id_token = lambda : "test-token"
354
+ with pytest .warns (DeprecationWarning ):
355
+ new_tool = auth_toolbox_tool .add_auth_token (
356
+ "test-auth-source" , get_id_token
357
+ )
358
+
359
+ # Check that the call was correctly forwarded to the new method on the core tool
360
+ mock_core_sync_auth_tool .add_auth_token_getters .assert_called_once_with (
361
+ {"test-auth-source" : get_id_token }
362
+ )
363
+ assert isinstance (new_tool , ToolboxTool )
0 commit comments