Skip to content

Commit 1c4121b

Browse files
mchadesCopilot
andcommitted
Fix test_authorization_with_existing_meta to actually test _meta merging
The previous test only verified authorization injection but did not pre-populate any _meta fields, making it indistinguishable from test_authorization_injected_in_meta. Now the test constructs a RequestParams with a pre-existing progressToken in _meta, then asserts that both progressToken and authorization are present after _send_request serialises the params - verifying that authorization is merged rather than replacing any existing _meta content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b1c878b commit 1c4121b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/test_client_session.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from adp_sdk.client import ClientSession
2222
from adp_sdk.client.session import basic_auth
23+
from adp_sdk.types.jsonrpc import RequestMeta, RequestParams
2324
from adp_sdk.shared import (
2425
ADPError,
2526
InvalidParamsError,
@@ -509,13 +510,18 @@ async def test_no_authorization_by_default(self) -> None:
509510
self.assertNotIn("authorization", meta)
510511

511512
async def test_authorization_with_existing_meta(self) -> None:
512-
"""Authorization is merged with existing _meta fields."""
513-
transport = _MockTransport([_make_init_response(), _make_discover_response()])
513+
"""Authorization is merged with existing _meta fields without overwriting them."""
514+
from adp_sdk.types.jsonrpc import EmptyResult
515+
516+
transport = _MockTransport([_make_init_response(), _make_ping_response()])
514517
async with ClientSession(transport, authorization="Basic dGVzdDo=") as session:
515-
await session.discover()
518+
params = RequestParams(meta=RequestMeta(progress_token=42))
519+
await session._send_request("adp.ping", params, EmptyResult)
516520

517521
data = json.loads(transport.written[1])
518-
self.assertEqual(data["params"]["_meta"]["authorization"], "Basic dGVzdDo=")
522+
meta = data["params"]["_meta"]
523+
self.assertEqual(meta["authorization"], "Basic dGVzdDo=")
524+
self.assertEqual(meta["progressToken"], 42)
519525

520526

521527
# ============================================================================

0 commit comments

Comments
 (0)