-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
932c37c
commit 08b75cf
Showing
11 changed files
with
147 additions
and
7 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# tests programmatic config of template sytem | ||
import pytest | ||
import os | ||
|
||
BASE_DIR = os.path.dirname(__file__) | ||
|
||
@pytest.fixture | ||
def voila_config(): | ||
def config(app): | ||
pass | ||
os.environ['JUPYTER_CONFIG_DIR'] = os.path.join(BASE_DIR, '../configs/general') | ||
yield config | ||
del os.environ['JUPYTER_CONFIG_DIR'] | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_lists_extension(http_client, base_url): | ||
response = yield http_client.fetch(base_url) | ||
assert response.code == 200 | ||
html_text = response.body.decode('utf-8') | ||
assert 'Hi Voila' in html_text | ||
assert 'ipytest/extension.js' in html_text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# test serving a notebook | ||
import pytest | ||
|
||
@pytest.fixture | ||
def voila_args(voila_notebook_dir, voila_args_extra): | ||
return ['--VoilaApp.root_dir=%r' % voila_notebook_dir, voila_notebook_dir, '--VoilaApp.log_level=DEBUG'] + voila_args_extra | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_hello_world(http_client, base_url): | ||
response = yield http_client.fetch(base_url + 'voila/render/print') | ||
assert response.code == 200 | ||
assert 'Hi Voila' in response.body.decode('utf-8') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import os | ||
|
||
import pytest | ||
from jupyter_server.serverapp import ServerApp | ||
from tornado import httpserver | ||
|
||
|
||
BASE_DIR = os.path.dirname(__file__) | ||
|
||
|
||
@pytest.fixture | ||
def jupyter_server_config(): | ||
return lambda app: None | ||
|
||
|
||
@pytest.fixture | ||
def jupyter_server_notebook(): | ||
return os.path.join(BASE_DIR, '../notebooks') | ||
|
||
|
||
@pytest.fixture | ||
def jupyter_server_args_extra(): | ||
return [] | ||
|
||
|
||
@pytest.fixture | ||
def print_notebook_url(base_url): | ||
return base_url + "/voila/render/print" | ||
|
||
|
||
@pytest.fixture | ||
def jupyter_server_args(jupyter_server_notebook, jupyter_server_args_extra): | ||
debug_args = ['--ServerApp.log_level=DEBUG'] if os.environ.get('VOILA_TEST_DEBUG', False) else [] | ||
default_args = ['--ServerApp.token=""'] | ||
return [jupyter_server_notebook] + jupyter_server_args_extra + debug_args + default_args | ||
|
||
|
||
@pytest.fixture | ||
def jupyter_server_app(jupyter_server_args, jupyter_server_config): | ||
jupyter_server_app = ServerApp.instance() | ||
# we monkey patch | ||
old_listen = httpserver.HTTPServer.listen | ||
httpserver.HTTPServer.listen = lambda *x, **y: None | ||
# NOTE: in voila's conftest.py we call config after initialize | ||
jupyter_server_config(jupyter_server_app) | ||
jupyter_server_app.initialize(jupyter_server_args) | ||
yield jupyter_server_app | ||
httpserver.HTTPServer.listen = old_listen | ||
ServerApp.clear_instance() | ||
|
||
|
||
|
||
|
||
@pytest.fixture | ||
def app(jupyter_server_app): | ||
return jupyter_server_app.web_app | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# test basics of voila running a notebook | ||
import pytest | ||
import tornado.web | ||
import tornado.gen | ||
import re | ||
import json | ||
|
||
try: | ||
from unittest import mock | ||
except: | ||
import mock | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_hello_world(http_client, print_notebook_url): | ||
response = yield http_client.fetch(print_notebook_url) | ||
assert response.code == 200 | ||
html_text = response.body.decode('utf-8') | ||
assert 'Hi Voila' in html_text | ||
assert 'gridstack.css' not in html_text, "gridstack should not be the default" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# tests programmatic config of template sytem | ||
import pytest | ||
import os | ||
|
||
BASE_DIR = os.path.dirname(__file__) | ||
|
||
@pytest.fixture | ||
def jupyter_server_config(): | ||
def config(app): | ||
pass | ||
os.environ['JUPYTER_CONFIG_DIR'] = os.path.join(BASE_DIR, 'configs', 'general') | ||
yield config | ||
del os.environ['JUPYTER_CONFIG_DIR'] | ||
|
||
@pytest.mark.xfail(reason='needs to be fixed') | ||
@pytest.mark.gen_test | ||
def test_lists_extension(http_client, print_notebook_url): | ||
response = yield http_client.fetch(print_notebook_url) | ||
assert response.code == 200 | ||
html_text = response.body.decode('utf-8') | ||
assert 'Hi Voila' in html_text | ||
assert 'ipytest/extension.js' in html_text |