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
09b0463
commit 94ed231
Showing
15 changed files
with
270 additions
and
11 deletions.
There are no files selected for viewing
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
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
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,27 @@ | ||
import os | ||
import pytest | ||
|
||
TEST_XEUS_CLING = os.environ.get('VOILA_TEST_XEUS_CLING', '') == '1' | ||
|
||
|
||
@pytest.fixture | ||
def cpp_file_url(base_url): | ||
return base_url + "/voila/render/print.xcpp" | ||
|
||
|
||
@pytest.fixture | ||
def voila_args_extra(): | ||
return ['--VoilaConfiguration.extension_language_mapping={".xcpp": "C++11"}'] | ||
|
||
|
||
@pytest.fixture | ||
def voila_args(notebook_directory, voila_args_extra): | ||
return ['--VoilaTest.root_dir=%r' % notebook_directory] + voila_args_extra | ||
|
||
|
||
@pytest.mark.skipif(not TEST_XEUS_CLING, reason='opt in to avoid having to install xeus-cling') | ||
@pytest.mark.gen_test | ||
def test_non_existing_kernel(http_client, cpp_file_url): | ||
response = yield http_client.fetch(cpp_file_url) | ||
assert response.code == 200 | ||
assert 'Hello voila, from c++' 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,40 @@ | ||
# test serving a notebook | ||
# test serving a notebook or python/c++ notebook | ||
import os | ||
import pytest | ||
|
||
TEST_XEUS_CLING = os.environ.get('VOILA_TEST_XEUS_CLING', '') == '1' | ||
|
||
|
||
@pytest.fixture | ||
def voila_args(notebook_directory, voila_args_extra): | ||
return ['--VoilaTest.root_dir=%r' % notebook_directory, '--VoilaTest.log_level=DEBUG'] + voila_args_extra | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_hello_world(http_client, print_notebook_url): | ||
def test_print(http_client, print_notebook_url): | ||
print(print_notebook_url) | ||
response = yield http_client.fetch(print_notebook_url) | ||
assert response.code == 200 | ||
assert 'Hi Voila' in response.body.decode('utf-8') | ||
|
||
|
||
@pytest.fixture | ||
def voila_args_extra(): | ||
return ['--VoilaConfiguration.extension_language_mapping={".py": "python"}'] | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_print_py(http_client, print_notebook_url): | ||
print(print_notebook_url) | ||
response = yield http_client.fetch(print_notebook_url.replace('ipynb', 'py')) | ||
assert response.code == 200 | ||
assert 'Hi Voila' in response.body.decode('utf-8') | ||
|
||
|
||
@pytest.mark.skipif(not TEST_XEUS_CLING, reason='opt in to avoid having to install xeus-cling') | ||
@pytest.mark.gen_test | ||
def test_print_julia_notebook(http_client, print_notebook_url): | ||
print(print_notebook_url) | ||
response = yield http_client.fetch(print_notebook_url.replace('.ipynb', '_cpp.ipynb')) | ||
assert response.code == 200 | ||
assert 'Hi Voila, from c++' 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# test tree rendering | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def voila_args(notebook_directory, voila_args_extra): | ||
return ['--VoilaTest.root_dir=%r' % notebook_directory, '--VoilaTest.log_level=DEBUG'] + voila_args_extra | ||
|
||
|
||
@pytest.fixture | ||
def voila_args_extra(): | ||
return ['--VoilaConfiguration.extension_language_mapping={".xcpp": "C++11"}'] | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_tree(http_client, base_url): | ||
response = yield http_client.fetch(base_url) | ||
assert response.code == 200 | ||
text = response.body.decode('utf-8') | ||
assert 'print.ipynb' in text, 'tree handler should render ipynb files' | ||
assert 'print.xcpp' in text, 'tree handler should render xcpp files (due to extension_language_mapping)' | ||
assert 'print.py' not in text, 'treeh handler should not render .py files (due to extension_language_mapping)' |
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,15 @@ | ||
# --- | ||
# jupyter: | ||
# jupytext: | ||
# text_representation: | ||
# extension: .py | ||
# format_name: light | ||
# format_version: '1.4' | ||
# jupytext_version: 1.2.1 | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python | ||
# --- | ||
|
||
print('Hi Voila!') |
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,23 @@ | ||
// --- | ||
// jupyter: | ||
// jupytext: | ||
// text_representation: | ||
// extension: .cpp | ||
// format_name: light | ||
// format_version: '1.4' | ||
// jupytext_version: 1.2.1 | ||
// kernelspec: | ||
// display_name: C++11 | ||
// language: C++11 | ||
// name: xcpp11 | ||
// --- | ||
|
||
|
||
// this is not a valid .cpp file, since it does not have a main() | ||
// however, we can ask voila to execute this by using the xeus-cling kernel | ||
// or relying on jupytext | ||
|
||
#include <iostream> | ||
using namespace std; | ||
|
||
cout << "Hello voila, from c++"; |
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,39 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#include <iostream>\n", | ||
"using namespace std;" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cout << \"Hi Voila, from c++\";" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "C++11", | ||
"language": "C++11", | ||
"name": "xcpp11" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": "text/x-c++src", | ||
"file_extension": ".cpp", | ||
"mimetype": "text/x-c++src", | ||
"name": "c++", | ||
"version": "-std=c++11" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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,27 @@ | ||
import os | ||
import pytest | ||
|
||
TEST_XEUS_CLING = os.environ.get('VOILA_TEST_XEUS_CLING', '') == '1' | ||
|
||
|
||
@pytest.fixture | ||
def cpp_file_url(base_url): | ||
return base_url + "/voila/render/print.xcpp" | ||
|
||
|
||
@pytest.fixture | ||
def jupyter_server_args_extra(): | ||
return ['--VoilaConfiguration.extension_language_mapping={".xcpp": "C++11"}'] | ||
|
||
|
||
@pytest.fixture | ||
def voila_args(notebook_directory, voila_args_extra): | ||
return ['--VoilaTest.root_dir=%r' % notebook_directory] + voila_args_extra | ||
|
||
|
||
@pytest.mark.skipif(not TEST_XEUS_CLING, reason='opt in to avoid having to install xeus-cling') | ||
@pytest.mark.gen_test | ||
def test_non_existing_kernel(http_client, cpp_file_url): | ||
response = yield http_client.fetch(cpp_file_url) | ||
assert response.code == 200 | ||
assert 'Hello voila, from c++' 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# test tree rendering | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def voila_args(notebook_directory, voila_args_extra): | ||
return ['--VoilaTest.root_dir=%r' % notebook_directory, '--VoilaTest.log_level=DEBUG'] + voila_args_extra | ||
|
||
|
||
@pytest.fixture | ||
def jupyter_server_args_extra(): | ||
return ['--VoilaConfiguration.extension_language_mapping={".xcpp": "C++11"}'] | ||
|
||
|
||
@pytest.mark.gen_test | ||
def test_tree(http_client, base_url): | ||
response = yield http_client.fetch(base_url+'/voila/tree') | ||
assert response.code == 200 | ||
text = response.body.decode('utf-8') | ||
assert 'print.ipynb' in text, 'tree handler should render ipynb files' | ||
assert 'print.xcpp' in text, 'tree handler should render xcpp files (due to extension_language_mapping)' | ||
assert 'print.py' not in text, 'tree handler should not render .py files (due to extension_language_mapping)' |
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
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
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
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
Oops, something went wrong.