Get baseline 100% clean coverage (#1553)
This commit is contained in:
parent
da4fce2195
commit
89e9c43acf
1 changed files with 1032 additions and 1084 deletions
|
|
@ -26,7 +26,7 @@ async def test_run_can_only_be_called_once():
|
|||
# Second call should raise RuntimeError
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
async with manager.run():
|
||||
pass
|
||||
pass # pragma: no cover
|
||||
|
||||
assert "StreamableHTTPSessionManager .run() can only be called once per instance" in str(excinfo.value)
|
||||
|
||||
|
|
@ -66,10 +66,10 @@ async def test_handle_request_without_run_raises_error():
|
|||
# Mock ASGI parameters
|
||||
scope = {"type": "http", "method": "POST", "path": "/test"}
|
||||
|
||||
async def receive():
|
||||
async def receive(): # pragma: no cover
|
||||
return {"type": "http.request", "body": b""}
|
||||
|
||||
async def send(message: Message):
|
||||
async def send(message: Message): # pragma: no cover
|
||||
pass
|
||||
|
||||
# Should raise error because run() hasn't been called
|
||||
|
|
@ -114,7 +114,7 @@ async def test_stateful_session_cleanup_on_graceful_exit(running_manager: tuple[
|
|||
"headers": [(b"content-type", b"application/json")],
|
||||
}
|
||||
|
||||
async def mock_receive():
|
||||
async def mock_receive(): # pragma: no cover
|
||||
return {"type": "http.request", "body": b"", "more_body": False}
|
||||
|
||||
# Trigger session creation
|
||||
|
|
@ -122,13 +122,13 @@ async def test_stateful_session_cleanup_on_graceful_exit(running_manager: tuple[
|
|||
|
||||
# Extract session ID from response headers
|
||||
session_id = None
|
||||
for msg in sent_messages:
|
||||
if msg["type"] == "http.response.start":
|
||||
for header_name, header_value in msg.get("headers", []):
|
||||
for msg in sent_messages: # pragma: no branch
|
||||
if msg["type"] == "http.response.start": # pragma: no branch
|
||||
for header_name, header_value in msg.get("headers", []): # pragma: no branch
|
||||
if header_name.decode().lower() == MCP_SESSION_ID_HEADER.lower():
|
||||
session_id = header_value.decode()
|
||||
break
|
||||
if session_id: # Break outer loop if session_id is found
|
||||
if session_id: # Break outer loop if session_id is found # pragma: no branch
|
||||
break
|
||||
|
||||
assert session_id is not None, "Session ID not found in response headers"
|
||||
|
|
@ -163,7 +163,7 @@ async def test_stateful_session_cleanup_on_exception(running_manager: tuple[Stre
|
|||
# If an exception occurs, the transport might try to send an error response
|
||||
# For this test, we mostly care that the session is established enough
|
||||
# to get an ID
|
||||
if message["type"] == "http.response.start" and message["status"] >= 500:
|
||||
if message["type"] == "http.response.start" and message["status"] >= 500: # pragma: no cover
|
||||
pass # Expected if TestException propagates that far up the transport
|
||||
|
||||
scope = {
|
||||
|
|
@ -173,20 +173,20 @@ async def test_stateful_session_cleanup_on_exception(running_manager: tuple[Stre
|
|||
"headers": [(b"content-type", b"application/json")],
|
||||
}
|
||||
|
||||
async def mock_receive():
|
||||
async def mock_receive(): # pragma: no cover
|
||||
return {"type": "http.request", "body": b"", "more_body": False}
|
||||
|
||||
# Trigger session creation
|
||||
await manager.handle_request(scope, mock_receive, mock_send)
|
||||
|
||||
session_id = None
|
||||
for msg in sent_messages:
|
||||
if msg["type"] == "http.response.start":
|
||||
for header_name, header_value in msg.get("headers", []):
|
||||
for msg in sent_messages: # pragma: no branch
|
||||
if msg["type"] == "http.response.start": # pragma: no branch
|
||||
for header_name, header_value in msg.get("headers", []): # pragma: no branch
|
||||
if header_name.decode().lower() == MCP_SESSION_ID_HEADER.lower():
|
||||
session_id = header_value.decode()
|
||||
break
|
||||
if session_id: # Break outer loop if session_id is found
|
||||
if session_id: # Break outer loop if session_id is found # pragma: no branch
|
||||
break
|
||||
|
||||
assert session_id is not None, "Session ID not found in response headers"
|
||||
|
|
|
|||
Loading…
Reference in a new issue