From f49f12cbe4b186105708baa24f1de86a43d66c63 Mon Sep 17 00:00:00 2001 From: Felipe Cardoso Date: Sat, 3 Jan 2026 16:19:54 +0100 Subject: [PATCH] fix(tests): use delay variables in retry delay test The delay2 and delay3 variables were calculated but never asserted, causing lint warnings. Added assertions to verify all delays are positive and within max bounds. --- backend/tests/services/mcp/test_routing.py | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/backend/tests/services/mcp/test_routing.py b/backend/tests/services/mcp/test_routing.py index a039637..3737c02 100644 --- a/backend/tests/services/mcp/test_routing.py +++ b/backend/tests/services/mcp/test_routing.py @@ -2,15 +2,13 @@ Tests for MCP Tool Call Routing """ -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import AsyncMock, patch import pytest from app.services.mcp.config import MCPConfig, MCPServerConfig from app.services.mcp.connection import ConnectionPool from app.services.mcp.exceptions import ( - MCPCircuitOpenError, - MCPToolError, MCPToolNotFoundError, ) from app.services.mcp.registry import MCPServerRegistry @@ -79,7 +77,10 @@ class TestToolInfo: name="create_issue", description="Create a new issue", server_name="issues", - input_schema={"type": "object", "properties": {"title": {"type": "string"}}}, + input_schema={ + "type": "object", + "properties": {"title": {"type": "string"}}, + }, ) assert info.name == "create_issue" assert info.description == "Create a new issue" @@ -174,9 +175,7 @@ class TestToolRouter: # Mock the pool connection and request mock_conn = AsyncMock() - mock_conn.execute_request = AsyncMock( - return_value={"result": {"status": "ok"}} - ) + mock_conn.execute_request = AsyncMock(return_value={"result": {"status": "ok"}}) mock_conn.is_connected = True with patch.object(router._pool, "get_connection", return_value=mock_conn): @@ -232,9 +231,7 @@ class TestToolRouter: await router.register_tool_mapping("tool-on-server-1", "server-1") mock_conn = AsyncMock() - mock_conn.execute_request = AsyncMock( - return_value={"result": "routed"} - ) + mock_conn.execute_request = AsyncMock(return_value={"result": "routed"}) mock_conn.is_connected = True with patch.object(router._pool, "get_connection", return_value=mock_conn): @@ -339,7 +336,11 @@ class TestToolRouter: delay2 = router._calculate_retry_delay(2, config) delay3 = router._calculate_retry_delay(3, config) - # Delays should increase with attempts + # All delays should be positive assert delay1 > 0 - # Allow for jitter variation + assert delay2 > 0 + assert delay3 > 0 + # All delays should be within max bounds (allow for jitter variation) assert delay1 <= config.retry_max_delay * 1.25 + assert delay2 <= config.retry_max_delay * 1.25 + assert delay3 <= config.retry_max_delay * 1.25