Skip to content

Commit

Permalink
Merge pull request #37 from afshin/update-pytest
Browse files Browse the repository at this point in the history
Update jupyter_server version, update to use prefixed fixtures
  • Loading branch information
blink1073 authored Dec 15, 2020
2 parents 75cebd7 + 2a86b95 commit 20fd125
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
python_requires='>=3.6',
include_package_data=True,
install_requires = [
'jupyter_server~=1.0.1',
'jupyter_server~=1.1',
'notebook<7',
],
entry_points = {
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from traitlets import default
from nbclassic.notebookapp import NotebookApp

pytest_plugins = ["jupyter_server.pytest_plugin"]


@pytest.fixture
def nbapp_log():
Expand Down Expand Up @@ -37,7 +39,7 @@ def _log_default(self):


@pytest.fixture
def server_config():
def jp_server_config():
return {
"ServerApp": {
"jpserver_extensions": {
Expand Down
26 changes: 13 additions & 13 deletions tests/shim/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _log_default(self):


@pytest.fixture
def server_config():
def jp_server_config():
return {
"ServerApp": {
"jpserver_extensions": {
Expand All @@ -52,8 +52,8 @@ def server_config():


@pytest.fixture
def extensionapp(serverapp):
return serverapp.extension_manager.extension_points["mockextension"].app
def extensionapp(jp_serverapp):
return jp_serverapp.extension_manager.extension_points["mockextension"].app


def list_test_params(param_input):
Expand All @@ -71,15 +71,15 @@ def list_test_params(param_input):


@pytest.mark.parametrize(
'argv,trait_name,trait_value',
'jp_argv,trait_name,trait_value',
list_test_params([
('enable_mathjax', False)
])
)
def test_EXTAPP_AND_NBAPP_SHIM_MSG(
extensionapp,
extapp_log,
argv,
jp_argv,
trait_name,
trait_value
):
Expand All @@ -92,7 +92,7 @@ def test_EXTAPP_AND_NBAPP_SHIM_MSG(


@pytest.mark.parametrize(
'argv,trait_name,trait_value',
'jp_argv,trait_name,trait_value',
list_test_params([
('allow_origin', ''),
('allow_origin_pat', ''),
Expand All @@ -101,7 +101,7 @@ def test_EXTAPP_AND_NBAPP_SHIM_MSG(
def test_EXTAPP_AND_SVAPP_SHIM_MSG(
extensionapp,
extapp_log,
argv,
jp_argv,
trait_name,
trait_value
):
Expand All @@ -114,7 +114,7 @@ def test_EXTAPP_AND_SVAPP_SHIM_MSG(


@pytest.mark.parametrize(
'argv,trait_name,trait_value',
'jp_argv,trait_name,trait_value',
list_test_params([
('jinja_environment_options', {}),
('jinja_template_vars', {}),
Expand All @@ -125,7 +125,7 @@ def test_EXTAPP_AND_SVAPP_SHIM_MSG(
def test_NOT_EXTAPP_NBAPP_AND_SVAPP_SHIM_MSG(
extensionapp,
extapp_log,
argv,
jp_argv,
trait_name,
trait_value
):
Expand All @@ -138,15 +138,15 @@ def test_NOT_EXTAPP_NBAPP_AND_SVAPP_SHIM_MSG(


@pytest.mark.parametrize(
'argv,trait_name,trait_value',
'jp_argv,trait_name,trait_value',
list_test_params([
('allow_credentials', False),
])
)
def test_EXTAPP_TO_SVAPP_SHIM_MSG(
extensionapp,
extapp_log,
argv,
jp_argv,
trait_name,
trait_value
):
Expand All @@ -159,7 +159,7 @@ def test_EXTAPP_TO_SVAPP_SHIM_MSG(


@pytest.mark.parametrize(
'argv,trait_name,trait_value',
'jp_argv,trait_name,trait_value',
list_test_params([
('mathjax_config', 'TEST'),
('mathjax_url', 'TEST')
Expand All @@ -168,7 +168,7 @@ def test_EXTAPP_TO_SVAPP_SHIM_MSG(
def test_EXTAPP_TO_NBAPP_SHIM_MSG(
extensionapp,
extapp_log,
argv,
jp_argv,
trait_name,
trait_value
):
Expand Down
22 changes: 11 additions & 11 deletions tests/shim/test_nbclassic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


@pytest.fixture
def server_config():
def jp_server_config():
return {
"ServerApp": {
"jpserver_extensions": {
Expand All @@ -15,8 +15,8 @@ def server_config():


@pytest.fixture
def nbclassic(serverapp):
return serverapp.extension_manager.extension_points["nbclassic"].app
def nbclassic(jp_serverapp):
return jp_serverapp.extension_manager.extension_points["nbclassic"].app


def list_test_params(param_input):
Expand All @@ -33,7 +33,7 @@ def list_test_params(param_input):


@pytest.mark.parametrize(
'argv,trait_name,trait_value',
'jp_argv,trait_name,trait_value',
list_test_params([
('jinja_environment_options', {}),
('jinja_template_vars', {}),
Expand All @@ -44,7 +44,7 @@ def list_test_params(param_input):
def test_NBAPP_AND_SVAPP_SHIM_MSG(
nbclassic,
nbapp_log,
argv,
jp_argv,
trait_name,
trait_value
):
Expand All @@ -56,7 +56,7 @@ def test_NBAPP_AND_SVAPP_SHIM_MSG(


@pytest.mark.parametrize(
'argv,trait_name,trait_value',
'jp_argv,trait_name,trait_value',
list_test_params([
('allow_origin', ''),
('allow_origin_pat', ''),
Expand All @@ -65,9 +65,9 @@ def test_NBAPP_AND_SVAPP_SHIM_MSG(
])
)
def test_NBAPP_TO_SVAPP_SHIM_MSG(
serverapp,
jp_serverapp,
nbapp_log,
argv,
jp_argv,
trait_name,
trait_value
):
Expand All @@ -77,11 +77,11 @@ def test_NBAPP_TO_SVAPP_SHIM_MSG(
# Verify a warning message was raised
assert expected_msg in log
# Verify that trait changed.
assert getattr(serverapp, trait_name) == trait_value
assert getattr(jp_serverapp, trait_name) == trait_value


@pytest.mark.parametrize(
'argv,trait_name,trait_value',
'jp_argv,trait_name,trait_value',
list_test_params([
#('ignore_minified_js', True),
('enable_mathjax', False),
Expand All @@ -91,7 +91,7 @@ def test_NBAPP_TO_SVAPP_SHIM_MSG(
)
def test_nbclassic_traits_pass_shim(
nbclassic,
argv,
jp_argv,
trait_name,
trait_value
):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@


@pytest.fixture
def notebooks(create_notebook):
def notebooks(jp_create_notebook):
nbpaths = (
'notebook1.ipynb',
'nbclassic_test_notebooks/notebook2.ipynb',
'nbclassic_test_notebooks/level2/notebook3.ipynb'
)
for nb in nbpaths:
create_notebook(nb)
jp_create_notebook(nb)
return nbpaths


async def test_tree_handler(notebooks, fetch):
r = await fetch('tree', 'nbclassic_test_notebooks')
async def test_tree_handler(notebooks, jp_fetch):
r = await jp_fetch('tree', 'nbclassic_test_notebooks')
assert r.code == 200

# Check that the tree template is loaded
Expand All @@ -27,9 +27,9 @@ async def test_tree_handler(notebooks, fetch):
assert "Clusters" in html


async def test_notebook_handler(notebooks, fetch):
async def test_notebook_handler(notebooks, jp_fetch):
for nbpath in notebooks:
r = await fetch('notebooks', nbpath)
r = await jp_fetch('notebooks', nbpath)
assert r.code == 200
# Check that the notebook template is loaded
html = r.body.decode()
Expand Down

0 comments on commit 20fd125

Please sign in to comment.