Skip to content

Commit 8e2b57e

Browse files
committed
try fix test
1 parent b78c0e7 commit 8e2b57e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/test_mcp_server.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ async def test_list_databases(mcp_server, setup_test_database):
9696
result = await client.call_tool("list_databases", {})
9797

9898
# The result should be a list containing at least one item
99-
assert len(result) >= 1
100-
assert isinstance(result[0].text, str)
99+
assert len(result.content) >= 1
100+
assert isinstance(result.text, str)
101101

102102
# Parse the result text (it's a JSON list of database names)
103-
databases = json.loads(result[0].text)
103+
databases = json.loads(result.content[0].text)
104104
assert test_db in databases
105105
assert "system" in databases # System database should always exist
106106

@@ -113,8 +113,8 @@ async def test_list_tables_basic(mcp_server, setup_test_database):
113113
async with Client(mcp_server) as client:
114114
result = await client.call_tool("list_tables", {"database": test_db})
115115

116-
assert len(result) >= 1
117-
tables = json.loads(result[0].text)
116+
assert len(result.content) >= 1
117+
tables = json.loads(result.content[0].text)
118118

119119
# Should have exactly 2 tables
120120
assert len(tables) == 2
@@ -149,7 +149,7 @@ async def test_list_tables_with_like_filter(mcp_server, setup_test_database):
149149
# Test with LIKE filter
150150
result = await client.call_tool("list_tables", {"database": test_db, "like": "test_%"})
151151

152-
tables_data = json.loads(result[0].text)
152+
tables_data = json.loads(result.content[0].text)
153153

154154
# Handle both single dict and list of dicts
155155
if isinstance(tables_data, dict):
@@ -170,7 +170,7 @@ async def test_list_tables_with_not_like_filter(mcp_server, setup_test_database)
170170
# Test with NOT LIKE filter
171171
result = await client.call_tool("list_tables", {"database": test_db, "not_like": "test_%"})
172172

173-
tables_data = json.loads(result[0].text)
173+
tables_data = json.loads(result.content[0].text)
174174

175175
# Handle both single dict and list of dicts
176176
if isinstance(tables_data, dict):
@@ -191,7 +191,7 @@ async def test_run_select_query_success(mcp_server, setup_test_database):
191191
query = f"SELECT id, name, age FROM {test_db}.{test_table} ORDER BY id"
192192
result = await client.call_tool("run_select_query", {"query": query})
193193

194-
query_result = json.loads(result[0].text)
194+
query_result = json.loads(result.content[0].text)
195195

196196
# Check structure
197197
assert "columns" in query_result
@@ -217,7 +217,7 @@ async def test_run_select_query_with_aggregation(mcp_server, setup_test_database
217217
query = f"SELECT COUNT(*) as count, AVG(age) as avg_age FROM {test_db}.{test_table}"
218218
result = await client.call_tool("run_select_query", {"query": query})
219219

220-
query_result = json.loads(result[0].text)
220+
query_result = json.loads(result.content[0].text)
221221

222222
assert query_result["columns"] == ["count", "avg_age"]
223223
assert len(query_result["rows"]) == 1
@@ -245,7 +245,7 @@ async def test_run_select_query_with_join(mcp_server, setup_test_database):
245245
"""
246246
result = await client.call_tool("run_select_query", {"query": query})
247247

248-
query_result = json.loads(result[0].text)
248+
query_result = json.loads(result.content[0].text)
249249
assert query_result["rows"][0][0] == 3 # login, logout, purchase
250250

251251

@@ -286,7 +286,7 @@ async def test_table_metadata_details(mcp_server, setup_test_database):
286286

287287
async with Client(mcp_server) as client:
288288
result = await client.call_tool("list_tables", {"database": test_db})
289-
tables = json.loads(result[0].text)
289+
tables = json.loads(result.content[0].text)
290290

291291
# Find our test table
292292
test_table_info = next(t for t in tables if t["name"] == test_table)
@@ -324,7 +324,7 @@ async def test_system_database_access(mcp_server):
324324
async with Client(mcp_server) as client:
325325
# List tables in system database
326326
result = await client.call_tool("list_tables", {"database": "system"})
327-
tables = json.loads(result[0].text)
327+
tables = json.loads(result.content[0].text)
328328

329329
# System database should have many tables
330330
assert len(tables) > 10
@@ -356,10 +356,10 @@ async def test_concurrent_queries(mcp_server, setup_test_database):
356356
)
357357

358358
# Verify all queries succeeded
359-
assert len(results) == 4
359+
assert len(result.content) == 4
360360

361361
# Check each result
362362
for i, result in enumerate(results):
363-
query_result = json.loads(result[0].text)
363+
query_result = json.loads(result.content[0].text)
364364
assert "rows" in query_result
365365
assert len(query_result["rows"]) == 1

0 commit comments

Comments
 (0)