Skip to content

Commit fa70273

Browse files
authored
Merge branch 'main' into renovate/python-nonmajor
2 parents 472e3d6 + 0ff650a commit fa70273

File tree

3 files changed

+36
-31
lines changed

3 files changed

+36
-31
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ If you are still having issues, please be sure to include as much information as
2020
- OS type and version:
2121
- Python version: `python --version`
2222
- pip version: `pip --version`
23-
- `toolbox-langchain` version: `pip show toolbox-langchain`
23+
- Version of the package you're using. Use `pip show <package-name>`
2424

2525
#### Steps to reproduce
2626

@@ -40,4 +40,4 @@ If you are still having issues, please be sure to include as much information as
4040

4141
Making sure to follow these steps will guarantee the quickest resolution possible.
4242

43-
Thanks!
43+
Thanks!

logo.png

-651 KB
Binary file not shown.

packages/toolbox-core/tests/test_tools.py renamed to packages/toolbox-core/tests/test_tool.py

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,30 +74,6 @@ def static_client_header() -> dict[str, str]:
7474
return {"X-Client-Static": "client-static-value"}
7575

7676

77-
@pytest.fixture
78-
def sync_callable_client_header_value() -> str:
79-
return "client-sync-callable-value"
80-
81-
82-
@pytest.fixture
83-
def sync_callable_client_header(sync_callable_client_header_value) -> dict[str, Mock]:
84-
return {"X-Client-Sync": Mock(return_value=sync_callable_client_header_value)}
85-
86-
87-
@pytest.fixture
88-
def async_callable_client_header_value() -> str:
89-
return "client-async-callable-value"
90-
91-
92-
@pytest.fixture
93-
def async_callable_client_header(
94-
async_callable_client_header_value,
95-
) -> dict[str, AsyncMock]:
96-
return {
97-
"X-Client-Async": AsyncMock(return_value=async_callable_client_header_value)
98-
}
99-
100-
10177
# --- Fixtures for Auth Getters ---
10278

10379

@@ -111,11 +87,6 @@ def auth_getters(auth_token_value) -> dict[str, Callable[[], str]]:
11187
return {"test-auth": lambda: auth_token_value}
11288

11389

114-
@pytest.fixture
115-
def auth_getters_mock(auth_token_value) -> dict[str, Mock]:
116-
return {"test-auth": Mock(return_value=auth_token_value)}
117-
118-
11990
@pytest.fixture
12091
def auth_header_key() -> str:
12192
return "test-auth_token"
@@ -421,3 +392,37 @@ def test_tool_init_header_auth_conflict(
421392
bound_params={},
422393
client_headers=conflicting_client_header,
423394
)
395+
396+
397+
def test_tool_add_auth_token_getters_conflict_with_existing_client_header(
398+
http_session: ClientSession,
399+
sample_tool_params: list[ParameterSchema],
400+
sample_tool_description: str,
401+
):
402+
"""
403+
Tests ValueError when add_auth_token_getters introduces an auth service
404+
whose token name conflicts with an existing client header.
405+
"""
406+
tool_instance = ToolboxTool(
407+
session=http_session,
408+
base_url=TEST_BASE_URL,
409+
name="tool_with_client_header",
410+
description=sample_tool_description,
411+
params=sample_tool_params,
412+
required_authn_params={},
413+
auth_service_token_getters={},
414+
bound_params={},
415+
client_headers={
416+
"X-Shared-Auth-Token_token": "value_from_initial_client_headers"
417+
},
418+
)
419+
new_auth_getters_causing_conflict = {
420+
"X-Shared-Auth-Token": lambda: "token_value_from_new_getter"
421+
}
422+
expected_error_message = (
423+
f"Client header\\(s\\) `X-Shared-Auth-Token_token` already registered in client. "
424+
f"Cannot register client the same headers in the client as well as tool."
425+
)
426+
427+
with pytest.raises(ValueError, match=expected_error_message):
428+
tool_instance.add_auth_token_getters(new_auth_getters_causing_conflict)

0 commit comments

Comments
 (0)