diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25ccd06..bc9bfed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,7 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' architecture: 'x64' - uses: actions/download-artifact@v4 with: diff --git a/README.md b/README.md index eb23bc1..6c75be7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # jupyter_server_documents -[![Github Actions Status](https://github.com/jupyter-ai-contrib/jupyter_server_documents/workflows/Build/badge.svg)](https://github.com/jupyter-ai-contrib/jupyter_server_documents/actions/workflows/build.yml) - A JupyterLab extension that provides RTC capabilities. This extension is composed of a Python package named `jupyter_server_documents` diff --git a/jupyter_server_documents/tests/test_output_processor.py b/jupyter_server_documents/tests/test_output_processor.py index 4b62dcf..dc7058c 100644 --- a/jupyter_server_documents/tests/test_output_processor.py +++ b/jupyter_server_documents/tests/test_output_processor.py @@ -1,13 +1,24 @@ import json +import pytest from pathlib import Path from tempfile import TemporaryDirectory from uuid import uuid4 from ..outputs import OutputProcessor, OutputsManager -class TestOutputProcessor(OutputProcessor): +class OutputProcessorForTest(OutputProcessor): + """Test subclass of OutputProcessor that overrides the settings property.""" + _test_settings = {} - settings = {} + @property + def settings(self): + """Override the settings property to return a test dictionary.""" + return self._test_settings + +@pytest.fixture +def output_processor(): + """Fixture that returns an instance of TestOutputProcessor.""" + return OutputProcessorForTest() def create_incoming_message(cell_id): msg_id = str(uuid4()) @@ -17,9 +28,9 @@ def create_incoming_message(cell_id): msg = [json.dumps(item) for item in [header, parent_header, metadata]] return msg_id, msg -def test_instantiation(): +def test_instantiation(output_processor): """Test instantiation of the output processor.""" - op = OutputProcessor() + op = output_processor assert isinstance(op, OutputProcessor) # TODO: Implement this diff --git a/jupyter_server_documents/tests/test_yroom_file_api.py b/jupyter_server_documents/tests/test_yroom_file_api.py index 80425fe..d2e29dd 100644 --- a/jupyter_server_documents/tests/test_yroom_file_api.py +++ b/jupyter_server_documents/tests/test_yroom_file_api.py @@ -13,6 +13,14 @@ from jupyter_server_fileid.manager import ArbitraryFileIdManager, BaseFileIdManager from jupyter_ydoc import YUnicode + +@pytest.fixture +def jp_contents_manager(tmp_path): + """A copy of the fixture from jupyter_server, to avoid duplicate runs + due to parameters in the original fixture""" + return AsyncFileContentsManager(root_dir=str(tmp_path), use_atomic_writing=False) + + @pytest.fixture def mock_plaintext_file(tmp_path): # Copy mock file to /tmp @@ -26,6 +34,9 @@ def mock_plaintext_file(tmp_path): # Cleanup os.remove(target_path) +def noop(): + pass + @pytest_asyncio.fixture(loop_scope="module") async def plaintext_file_api(mock_plaintext_file: str, jp_contents_manager: AsyncFileContentsManager): """ @@ -38,7 +49,8 @@ async def plaintext_file_api(mock_plaintext_file: str, jp_contents_manager: Asyn contents_manager = jp_contents_manager loop = asyncio.get_running_loop() - file_id = fileid_manager.index(mock_plaintext_file) + filename = os.path.basename(mock_plaintext_file) + file_id = fileid_manager.index(filename) room_id = f"text:file:{file_id}" ydoc = pycrdt.Doc() awareness = pycrdt.Awareness(ydoc=ydoc) @@ -50,6 +62,9 @@ async def plaintext_file_api(mock_plaintext_file: str, jp_contents_manager: Asyn fileid_manager=fileid_manager, log=log, loop=loop, + on_inband_deletion=noop, + on_outofband_change=noop, + on_outofband_move=noop ) return yroom_file_api @@ -59,7 +74,7 @@ async def test_load_plaintext_file(plaintext_file_api: Awaitable[YRoomFileAPI], file_api = await plaintext_file_api jupyter_ydoc = file_api.jupyter_ydoc file_api.load_ydoc_content() - await file_api.ydoc_content_loaded + await file_api.ydoc_content_loaded.wait() # Assert that `get_jupyter_ydoc()` returns a `jupyter_ydoc.YUnicode` object # for plaintext files @@ -69,4 +84,7 @@ async def test_load_plaintext_file(plaintext_file_api: Awaitable[YRoomFileAPI], with open(mock_plaintext_file) as f: content = f.read() assert jupyter_ydoc.source == content + + # stop file file api to avoid coroutine warnings + file_api.stop()