Skip to content

Commit

Permalink
Require jupyter-server
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Feb 10, 2024
1 parent 7142d52 commit eecc306
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
2 changes: 2 additions & 0 deletions dev-requirements-jl3.old
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
-r dev-requirements.txt
jupyterlab==3.6.7
# Also test the old version of jupyter_server
jupyter_server==1.24.0
1 change: 1 addition & 0 deletions dev-requirements-jl4.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-r dev-requirements.txt
jupyterlab==4.1.0
jupyter_server==2.12.5
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
jupyter_packaging==0.12.3
flaky==3.7.0
notebook==6.5.4
nbclassic==1.0.0
pre-commit==2.21.0
pytest==7.4.4
selenium==4.11.2
traitlets==5.9.0
wheel==0.42.0
# jupyterlab is installed separately so we can test multiple versions
# jupyterlab and jupyter_server are installed separately so we can test multiple versions
6 changes: 3 additions & 3 deletions jupyter_offlinenotebook/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from notebook.utils import url_path_join
from notebook.base.handlers import IPythonHandler
from jupyter_server.utils import url_path_join
from jupyter_server.base.handlers import JupyterHandler
import os
from tornado import web
from traitlets import TraitType
Expand All @@ -23,7 +23,7 @@ def validate(self, obj, value):
self.error(obj, value)


class OfflineNotebookHandler(IPythonHandler):
class OfflineNotebookHandler(JupyterHandler):
@web.authenticated
async def get(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_version():
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
cmdclass=cmdclass,
install_requires=[],
install_requires=["jupyter-server"],
python_requires=">=3.6",
zip_safe=False,
include_package_data=True,
Expand Down
20 changes: 9 additions & 11 deletions tests/test_offlinenotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@ def start_jupyter(self, jupyterdir, app):
workspaces_dir = jupyterdir / "workspaces"
workspaces_dir.mkdir()

version = subprocess.check_output(
["jupyter-{}".format(app.lower()), "--version"]
)
version = subprocess.check_output([f"jupyter-{app}", "--version"])
self.major_version = int(version.split(b".", 1)[0])
command = [
"jupyter-{}".format(app.lower()),
f"jupyter-{app}",
"--no-browser",
"--{}App.token=".format(app),
"--port={}".format(PORT),
"--ServerApp.token=",
f"--port={PORT}",
]
env = {
"BINDER_LAUNCH_HOST": "http://localhost/",
Expand Down Expand Up @@ -188,13 +186,15 @@ def wait_for_modal_dialog(self):
(By.XPATH, "//div[@class='modal-backdrop']")
)
)
# Still doesn't work so force a pause
sleep(0.5)

@pytest.mark.flaky(max_runs=3)
def test_offline_notebook(self, tmpdir):
# Selenium can't access IndexedDB so instead check save/load by
# downloading the updated notebook

self.initialise(tmpdir, "Notebook", JUPYTERNOTEBOOK_URL)
self.initialise(tmpdir, "nbclassic", JUPYTERNOTEBOOK_URL)

size, ncells = self.download_visible()
assert_expected_size(size)
Expand All @@ -206,8 +206,6 @@ def test_offline_notebook(self, tmpdir):
# Delete some cells and download
# element_to_be_clickable doesn't actually mean clickable
self.wait_for_modal_dialog()
# Still doesn't work so force a pause
sleep(0.5)
for n in range(EXPECTED_NUM_CELLS):
self.wait.until(
EC.element_to_be_clickable(
Expand Down Expand Up @@ -292,7 +290,7 @@ def test_offline_lab(self, tmpdir):
# Selenium can't access IndexedDB so instead check save/load by
# downloading the updated notebook

self.initialise(tmpdir, "Lab", JUPYTERLAB_URL)
self.initialise(tmpdir, "lab", JUPYTERLAB_URL)
assert self.major_version in (3, 4)
if self.major_version == 3:
self.toolbar_button = "button"
Expand Down Expand Up @@ -343,7 +341,7 @@ def test_offline_lab(self, tmpdir):

class TestServer(FirefoxTestBase):
def test_server_config(self, tmpdir):
self.start_jupyter(tmpdir, "Notebook")
self.start_jupyter(tmpdir, "server")
# Wait for server to start
sleep(2)

Expand Down

0 comments on commit eecc306

Please sign in to comment.