Skip to content
Open
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
4 changes: 2 additions & 2 deletions jupyter_ydoc/ynotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ def get(self) -> Dict:
return dict(
cells=cells,
metadata=meta.get("metadata", {}),
nbformat=int(meta.get("nbformat", 0)),
nbformat_minor=int(meta.get("nbformat_minor", 0)),
nbformat=int(meta.get("nbformat", NBFORMAT_MAJOR_VERSION)),
nbformat_minor=int(meta.get("nbformat_minor", NBFORMAT_MINOR_VERSION)),
)

def set(self, value: Dict) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test = [
"pytest",
"pytest-asyncio",
"websockets >=10.0",
"ypy-websocket >=0.8.3,<0.9.0",
"ypy-websocket >=0.8.3,<0.13.0",
]
docs = [
"sphinx",
Expand Down
8 changes: 6 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ async def yws_server(request):
kwargs = request.param
except Exception:
kwargs = {}

websocket_server = WebsocketServer(**kwargs)
async with serve(websocket_server.serve, "localhost", 1234):
yield websocket_server
try:
async with websocket_server, serve(websocket_server.serve, "localhost", 1234):
yield websocket_server
except Exception:
pass


@pytest.fixture
Expand Down
16 changes: 9 additions & 7 deletions tests/test_ypy_yjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ def source(self):
async def test_ypy_yjs_0(yws_server, yjs_client):
ydoc = Y.YDoc()
ynotebook = YNotebook(ydoc)
websocket = await connect("ws://localhost:1234/my-roomname")
WebsocketProvider(ydoc, websocket)
nb = stringify_source(json.loads((files_dir / "nb0.ipynb").read_text()))
ynotebook.source = nb
ytest = YTest(ydoc, 3.0)
await ytest.change()
assert ytest.source == nb

async with connect("ws://localhost:1234/my-roomname") as websocket, WebsocketProvider(
ydoc, websocket
):
nb = stringify_source(json.loads((files_dir / "nb0.ipynb").read_text()))
ynotebook.source = nb
ytest = YTest(ydoc, 3.0)
await ytest.change()
assert ytest.source == nb


def test_plotly_renderer():
Expand Down