Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
19 changes: 15 additions & 4 deletions jupyter_server_documents/tests/test_output_processor.py
Original file line number Diff line number Diff line change
@@ -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())
Expand All @@ -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
Expand Down
22 changes: 20 additions & 2 deletions jupyter_server_documents/tests/test_yroom_file_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
"""
Expand All @@ -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)
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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()

Loading