@@ -1443,23 +1443,41 @@ async def test_add_headers_success(
1443
1443
)
1444
1444
1445
1445
async with ToolboxClient (TEST_BASE_URL ) as client :
1446
- client .add_headers (static_header )
1446
+ with pytest .warns (
1447
+ DeprecationWarning ,
1448
+ match = "Use the `client_headers` parameter in the ToolboxClient constructor instead." ,
1449
+ ):
1450
+ client .add_headers (static_header )
1447
1451
assert client ._ToolboxClient__client_headers == static_header
1448
1452
1449
1453
tool = await client .load_tool (tool_name )
1450
1454
result = await tool (param1 = "test" )
1451
1455
assert result == expected_payload ["result" ]
1452
1456
1457
+ @pytest .mark .asyncio
1458
+ async def test_add_headers_deprecation_warning (self ):
1459
+ """Tests that add_headers issues a DeprecationWarning."""
1460
+ async with ToolboxClient (TEST_BASE_URL ) as client :
1461
+ with pytest .warns (
1462
+ DeprecationWarning ,
1463
+ match = "Use the `client_headers` parameter in the ToolboxClient constructor instead." ,
1464
+ ):
1465
+ client .add_headers ({"X-Deprecated-Test" : "value" })
1466
+
1453
1467
@pytest .mark .asyncio
1454
1468
async def test_add_headers_duplicate_fail (self , static_header ):
1455
1469
"""Tests that adding a duplicate header via add_headers raises
1456
1470
ValueError."""
1457
1471
async with ToolboxClient (TEST_BASE_URL , client_headers = static_header ) as client :
1458
- with pytest .raises (
1459
- ValueError ,
1460
- match = f"Client header \\ (s \\ ) `X-Static-Header` already registered " ,
1472
+ with pytest .warns (
1473
+ DeprecationWarning ,
1474
+ match = "Use the `client_headers` parameter in the ToolboxClient constructor instead. " ,
1461
1475
):
1462
- await client .add_headers (static_header )
1476
+ with pytest .raises (
1477
+ ValueError ,
1478
+ match = f"Client header\\ (s\\ ) `X-Static-Header` already registered" ,
1479
+ ):
1480
+ client .add_headers (static_header )
1463
1481
1464
1482
@pytest .mark .asyncio
1465
1483
async def test_client_header_auth_token_conflict_fail (
0 commit comments