Skip to content

Commit 2e6cf59

Browse files
committed
add q fallback test case
resolve coverage error
1 parent 01b8f20 commit 2e6cf59

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/shared/test_streamable_http.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,21 @@ async def test_accept_header_respects_q_zero(basic_app: Starlette, accept_header
461461
assert response.status_code == 406
462462

463463

464+
@pytest.mark.anyio
465+
async def test_accept_header_invalid_q_falls_back_to_default_weight(basic_app: Starlette) -> None:
466+
"""Malformed q parameters fall back to the default weight and still allow the media type."""
467+
async with make_client(basic_app) as client:
468+
response = await client.post(
469+
"/mcp",
470+
headers={
471+
"Accept": "application/json;foo=bar;q=not-a-number, text/event-stream",
472+
"Content-Type": "application/json",
473+
},
474+
json=INIT_REQUEST,
475+
)
476+
assert response.status_code == 200
477+
478+
464479
@pytest.mark.anyio
465480
@pytest.mark.parametrize(
466481
"accept_header",

0 commit comments

Comments
 (0)