|
1 | | -from unittest.mock import AsyncMock, patch |
| 1 | +from unittest.mock import AsyncMock, MagicMock, patch |
2 | 2 | import httpx |
3 | 3 | import pytest |
4 | 4 | from werkzeug.wrappers import Response |
|
7 | 7 |
|
8 | 8 |
|
9 | 9 | # Sync tests for the ep.make() function |
10 | | -@pytest.mark.asyncio |
11 | | -async def test_mcp_env_make_appends_trailing_slash(): |
| 10 | +def test_mcp_env_make_appends_trailing_slash(): |
12 | 11 | """ |
13 | 12 | Verify that ep.make() appends a trailing slash to the MCP server URL if it's missing. |
14 | 13 | This prevents 307 redirects that can break HTTP clients. |
15 | 14 | """ |
16 | 15 | base_url = "http://localhost:8000/mcp" |
17 | 16 | corrected_url = "http://localhost:8000/mcp/" |
18 | 17 |
|
19 | | - with patch( |
20 | | - "eval_protocol.mcp.client.connection.MCPConnectionManager.initialize_session", |
21 | | - new_callable=AsyncMock, |
22 | | - ) as mock_init: |
23 | | - mock_init.return_value = None |
24 | | - |
25 | | - envs = ep.make(base_url, n=1, seeds=[42]) |
26 | | - |
27 | | - mock_init.assert_awaited_once() |
| 18 | + envs = ep.make(base_url, n=1, seeds=[42]) |
28 | 19 |
|
29 | 20 | assert len(envs.sessions) == 1 |
30 | 21 | assert envs.sessions[0].base_url == corrected_url |
31 | 22 |
|
32 | 23 |
|
33 | | -@pytest.mark.asyncio |
34 | | -async def test_mcp_env_make_keeps_existing_trailing_slash(): |
| 24 | +def test_mcp_env_make_keeps_existing_trailing_slash(): |
35 | 25 | """ |
36 | 26 | Verify that ep.make() does not add an extra slash if one is already present. |
37 | 27 | """ |
38 | 28 | base_url = "http://localhost:8000/mcp/" |
39 | 29 |
|
40 | | - with patch( |
41 | | - "eval_protocol.mcp.client.connection.MCPConnectionManager.initialize_session", |
42 | | - new_callable=AsyncMock, |
43 | | - ) as mock_init: |
44 | | - mock_init.return_value = None |
45 | | - |
46 | | - envs = ep.make(base_url, n=1, seeds=[42]) |
47 | | - |
48 | | - mock_init.assert_awaited_once() |
| 30 | + envs = ep.make(base_url, n=1, seeds=[42]) |
49 | 31 |
|
50 | 32 | assert len(envs.sessions) == 1 |
51 | 33 | # The session's base_url should remain unchanged |
|
0 commit comments