diff --git a/projects/jupyter-server-ydoc/jupyter_server_ydoc/test_utils.py b/projects/jupyter-server-ydoc/jupyter_server_ydoc/test_utils.py index 8114b673..f1140322 100644 --- a/projects/jupyter-server-ydoc/jupyter_server_ydoc/test_utils.py +++ b/projects/jupyter-server-ydoc/jupyter_server_ydoc/test_utils.py @@ -16,6 +16,9 @@ def __init__(self, mapping: dict): def get_path(self, id: str) -> str: return self.mapping[id] + def move(self, id: str, new_path: str) -> None: + self.mapping[id] = new_path + class FakeContentsManager: def __init__(self, model: dict): diff --git a/tests/test_rooms.py b/tests/test_rooms.py index b3f58872..2bdfa04a 100644 --- a/tests/test_rooms.py +++ b/tests/test_rooms.py @@ -75,3 +75,22 @@ async def test_undefined_save_delay_should_not_save_content_after_document_chang await asyncio.sleep(0.15) assert "save" not in cm.actions + + +async def test_document_path(rtc_create_mock_document_room): + id = "test-id" + path = "test.txt" + new_path = "test2.txt" + + _, loader, room = rtc_create_mock_document_room(id, path, "") + + await room.initialize() + assert room._document.path == path + + # Update the path + loader._file_id_manager.move(id, new_path) + + # Wait for a bit more than the poll_interval + await asyncio.sleep(0.15) + + assert room._document.path == new_path