Skip to content

Commit 970acf9

Browse files
committed
Fix linting issues in MCP tool registration tests
- Remove unused httpx import - Remove unused mock_mcp_tool variable assignments - Sort imports properly - Remove trailing whitespace from blank lines
1 parent 12bc3e8 commit 970acf9

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

tests/tooling/extensions/agentframework/services/test_mcp_tool_registration_service.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
errors when calling MCP tool servers.
1313
"""
1414

15-
from unittest.mock import AsyncMock, Mock, patch, MagicMock
16-
import pytest
17-
import httpx
15+
from unittest.mock import AsyncMock, MagicMock, Mock, patch
1816

17+
import pytest
1918
from microsoft_agents_a365.tooling.extensions.agentframework.services import (
2019
McpToolRegistrationService,
2120
)
@@ -92,7 +91,7 @@ async def test_httpx_client_has_authorization_header(
9291
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.httpx.AsyncClient"
9392
) as mock_httpx_client, patch(
9493
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.MCPStreamableHTTPTool"
95-
) as mock_mcp_tool, patch(
94+
), patch(
9695
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.ChatAgent"
9796
), patch(
9897
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.Utility.resolve_agent_identity",
@@ -145,7 +144,7 @@ async def test_httpx_client_has_user_agent_header(
145144
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.httpx.AsyncClient"
146145
) as mock_httpx_client, patch(
147146
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.MCPStreamableHTTPTool"
148-
) as mock_mcp_tool, patch(
147+
), patch(
149148
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.ChatAgent"
150149
), patch(
151150
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.Utility.resolve_agent_identity",
@@ -196,7 +195,7 @@ async def test_httpx_client_has_correct_timeout(
196195
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.httpx.AsyncClient"
197196
) as mock_httpx_client, patch(
198197
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.MCPStreamableHTTPTool"
199-
) as mock_mcp_tool, patch(
198+
), patch(
200199
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.ChatAgent"
201200
), patch(
202201
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.Utility.resolve_agent_identity",
@@ -236,7 +235,7 @@ async def test_mcp_tool_receives_http_client_not_headers(
236235
mock_mcp_server_config,
237236
):
238237
"""Test that MCPStreamableHTTPTool is instantiated with http_client parameter.
239-
238+
240239
This is the critical test that prevents regression to the bug where
241240
headers were passed directly to MCPStreamableHTTPTool and silently ignored.
242241
The fix passes an httpx.AsyncClient with pre-configured headers instead.
@@ -307,7 +306,7 @@ async def test_httpx_client_added_to_internal_list_for_cleanup(
307306
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.httpx.AsyncClient"
308307
) as mock_httpx_client, patch(
309308
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.MCPStreamableHTTPTool"
310-
) as mock_mcp_tool, patch(
309+
), patch(
311310
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.ChatAgent"
312311
), patch(
313312
"microsoft_agents_a365.tooling.extensions.agentframework.services.mcp_tool_registration_service.Utility.resolve_agent_identity",
@@ -388,7 +387,7 @@ async def test_cleanup_handles_client_close_errors_gracefully(self, service):
388387

389388
class TestHttpxClientLifecycle:
390389
"""End-to-end tests for httpx client lifecycle management.
391-
390+
392391
These tests verify that clients created during add_tool_servers_to_agent()
393392
are properly tracked and cleaned up by cleanup(), preventing connection
394393
and file descriptor leaks.
@@ -437,7 +436,7 @@ async def test_full_client_lifecycle_single_server(
437436
mock_chat_client,
438437
):
439438
"""Test full lifecycle: create client via add_tool_servers, then cleanup.
440-
439+
441440
This end-to-end test ensures that:
442441
1. add_tool_servers_to_agent() creates and tracks httpx clients
443442
2. cleanup() calls aclose() on each tracked client
@@ -504,7 +503,7 @@ async def test_full_client_lifecycle_multiple_servers(
504503
mock_chat_client,
505504
):
506505
"""Test lifecycle with multiple MCP servers creating multiple clients.
507-
506+
508507
Verifies that when multiple tool servers are configured, each gets its
509508
own httpx client that is properly tracked and cleaned up.
510509
"""
@@ -578,7 +577,7 @@ async def test_full_client_lifecycle_multiple_servers(
578577
@pytest.mark.unit
579578
async def test_cleanup_idempotent_no_clients(self, service):
580579
"""Test that cleanup() is safe to call when no clients exist.
581-
580+
582581
Ensures cleanup doesn't raise errors when called on a fresh service
583582
or called multiple times.
584583
"""
@@ -605,7 +604,7 @@ async def test_cleanup_called_twice_after_creating_clients(
605604
mock_chat_client,
606605
):
607606
"""Test that calling cleanup() twice doesn't cause issues.
608-
607+
609608
After the first cleanup, the list is cleared, so the second cleanup
610609
should be a no-op without errors.
611610
"""

0 commit comments

Comments
 (0)