Skip to content

Commit 24217ae

Browse files
committed
fix(tests): update test_integration.py for initialize_result
Main added 11 client.server_capabilities callsites while this branch was in flight. Each was a 2-line narrowing-check-then-real-check pair; collapses to 1 line since initialize_result is non-nullable. Github-Issue: #1018
1 parent 668d172 commit 24217ae

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

tests/server/mcpserver/test_integration.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ async def elicitation_callback(context: RequestContext[ClientSession], params: E
109109
async def test_basic_tools() -> None:
110110
"""Test basic tool functionality."""
111111
async with Client(basic_tool.mcp) as client:
112-
assert client.server_capabilities is not None
113-
assert client.server_capabilities.tools is not None
112+
assert client.initialize_result.capabilities.tools is not None
114113

115114
# Test sum tool
116115
tool_result = await client.call_tool("sum", {"a": 5, "b": 3})
@@ -128,8 +127,7 @@ async def test_basic_tools() -> None:
128127
async def test_basic_resources() -> None:
129128
"""Test basic resource functionality."""
130129
async with Client(basic_resource.mcp) as client:
131-
assert client.server_capabilities is not None
132-
assert client.server_capabilities.resources is not None
130+
assert client.initialize_result.capabilities.resources is not None
133131

134132
# Test document resource
135133
doc_content = await client.read_resource("file://documents/readme")
@@ -151,8 +149,7 @@ async def test_basic_resources() -> None:
151149
async def test_basic_prompts() -> None:
152150
"""Test basic prompt functionality."""
153151
async with Client(basic_prompt.mcp) as client:
154-
assert client.server_capabilities is not None
155-
assert client.server_capabilities.prompts is not None
152+
assert client.initialize_result.capabilities.prompts is not None
156153

157154
# Test review_code prompt
158155
prompts = await client.list_prompts()
@@ -223,8 +220,7 @@ async def progress_callback(progress: float, total: float | None, message: str |
223220
async def test_sampling() -> None:
224221
"""Test sampling (LLM interaction) functionality."""
225222
async with Client(sampling.mcp, sampling_callback=sampling_callback) as client:
226-
assert client.server_capabilities is not None
227-
assert client.server_capabilities.tools is not None
223+
assert client.initialize_result.capabilities.tools is not None
228224

229225
# Test sampling tool
230226
sampling_result = await client.call_tool("generate_poem", {"topic": "nature"})
@@ -294,9 +290,8 @@ async def message_handler(message: RequestResponder[ServerRequest, ClientResult]
294290
async def test_completion() -> None:
295291
"""Test completion (autocomplete) functionality."""
296292
async with Client(completion.mcp) as client:
297-
assert client.server_capabilities is not None
298-
assert client.server_capabilities.resources is not None
299-
assert client.server_capabilities.prompts is not None
293+
assert client.initialize_result.capabilities.resources is not None
294+
assert client.initialize_result.capabilities.prompts is not None
300295

301296
# Test resource completion
302297
completion_result = await client.complete(

0 commit comments

Comments
 (0)