Skip to content

Commit 3b374ad

Browse files
committed
added tests
1 parent 0b5e106 commit 3b374ad

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

packages/toolbox-langchain/tests/test_async_client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,22 @@ async def test_load_toolset_not_implemented(self, mock_client):
339339
assert "Synchronous methods not supported by async client." in str(
340340
excinfo.value
341341
)
342+
343+
@patch("toolbox_langchain.async_client.ToolboxCoreClient")
344+
async def test_init_with_client_headers(
345+
self, mock_core_client_constructor, mock_session
346+
):
347+
"""Tests that client_headers are passed to the core client during initialization."""
348+
headers = {"X-Test-Header": "value"}
349+
AsyncToolboxClient(URL, session=mock_session, client_headers=headers)
350+
mock_core_client_constructor.assert_called_once_with(
351+
url=URL, session=mock_session, client_headers=headers
352+
)
353+
354+
async def test_add_headers(self, mock_client):
355+
"""Tests that add_headers calls the core client's add_headers."""
356+
headers = {"X-Another-Header": lambda: "dynamic_value"}
357+
mock_client.add_headers(headers)
358+
mock_client._AsyncToolboxClient__core_client.add_headers.assert_called_once_with(
359+
headers
360+
)

packages/toolbox-langchain/tests/test_client.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,21 @@ async def test_aload_toolset_with_args(
420420
bound_params=bound_params,
421421
strict=True,
422422
)
423+
424+
@patch("toolbox_langchain.client.ToolboxCoreSyncClient")
425+
def test_init_with_client_headers(self, mock_core_client_constructor):
426+
"""Tests that client_headers are passed to the core client during initialization."""
427+
headers = {"X-Test-Header": "value"}
428+
ToolboxClient(URL, client_headers=headers)
429+
mock_core_client_constructor.assert_called_once_with(
430+
url=URL, client_headers=headers
431+
)
432+
433+
@patch("toolbox_langchain.client.ToolboxCoreSyncClient")
434+
def test_add_headers(self, mock_core_client_constructor):
435+
"""Tests that add_headers calls the core client's add_headers."""
436+
mock_core_instance = mock_core_client_constructor.return_value
437+
client = ToolboxClient(URL)
438+
headers = {"X-Another-Header": "dynamic_value"}
439+
client.add_headers(headers)
440+
mock_core_instance.add_headers.assert_called_once_with(headers)

0 commit comments

Comments
 (0)