Skip to content

Commit 46a29d2

Browse files
fix: better and more faster test (datalayer#137)
* better test * fix and disable check_links
1 parent 22dafb7 commit 46a29d2

File tree

5 files changed

+118
-918
lines changed

5 files changed

+118
-918
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ jobs:
4848
name: jupyter_mcp_server-sdist-${{ matrix.python-version }}
4949
path: jupyter_mcp_server.tar.gz
5050

51-
check_links:
52-
runs-on: ubuntu-latest
53-
steps:
54-
- uses: actions/checkout@v5
55-
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
56-
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
51+
# check_links:
52+
# runs-on: ubuntu-latest
53+
# steps:
54+
# - uses: actions/checkout@v5
55+
# - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
56+
# - uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
5757

5858
test_lint:
5959
runs-on: ubuntu-latest

tests/test_common.py

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from contextlib import AsyncExitStack
2121

2222
import pytest
23+
import requests
2324
from mcp import ClientSession, types
2425
from mcp.client.streamable_http import streamablehttp_client
2526

@@ -346,30 +347,9 @@ async def read_cells(self):
346347
@requires_session
347348
async def list_cells(self, max_retries=3):
348349
"""List cells with retry mechanism for Windows compatibility"""
349-
for attempt in range(max_retries):
350-
try:
351-
result = await self._session.call_tool("list_cells") # type: ignore
352-
text_result = self._extract_text_content(result)
353-
logging.debug(f"list_cells attempt {attempt + 1}: text_result type={type(text_result)}, len={len(text_result) if text_result else 0}")
354-
logging.debug(f"list_cells attempt {attempt + 1}: text_result[:500]={repr(text_result[:500]) if text_result else 'None'}")
355-
has_index_type = ("Index\tType" in text_result) if text_result else False
356-
logging.debug(f"list_cells attempt {attempt + 1}: has_index_type={has_index_type}")
357-
if text_result is not None and not text_result.startswith("Error") and "Index\tType" in text_result:
358-
return text_result
359-
else:
360-
logging.warning(f"list_cells returned unexpected result on attempt {attempt + 1}/{max_retries}")
361-
if attempt < max_retries - 1:
362-
await asyncio.sleep(0.5)
363-
except Exception as e:
364-
logging.error(f"list_cells failed on attempt {attempt + 1}/{max_retries}: {e}")
365-
if attempt < max_retries - 1:
366-
await asyncio.sleep(0.5)
367-
else:
368-
logging.error("list_cells failed after all retries")
369-
return "Error: Failed to retrieve cell list after all retries"
370-
371-
return "Error: Failed to retrieve cell list after all retries"
372-
350+
result = await self._session.call_tool("list_cells") # type: ignore
351+
return self._extract_text_content(result)
352+
373353
@requires_session
374354
async def list_kernels(self):
375355
"""List all available kernels"""
@@ -437,24 +417,3 @@ async def execute_code(self, code, timeout=60):
437417
structured["result"] = [result_val]
438418

439419
return structured
440-
441-
@requires_session
442-
async def append_execute_code_cell(self, cell_source):
443-
"""Append and execute a code cell at the end of the notebook."""
444-
return await self.insert_execute_code_cell(-1, cell_source)
445-
446-
@requires_session
447-
async def append_markdown_cell(self, cell_source):
448-
"""Append a markdown cell at the end of the notebook."""
449-
return await self.insert_cell(-1, "markdown", cell_source)
450-
451-
# Helper method to get cell count from list_cells output
452-
@requires_session
453-
async def get_cell_count(self):
454-
"""Get the number of cells by parsing list_cells output"""
455-
cell_list = await self.list_cells()
456-
if "Error" in cell_list or "Index\tType" not in cell_list:
457-
return 0
458-
lines = cell_list.split('\n')
459-
data_lines = [line for line in lines if '\t' in line and not line.startswith('Index') and not line.startswith('-')]
460-
return len(data_lines)

tests/test_list_kernels.py

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)