Skip to content

Commit

Permalink
Disable preheat mode for old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Oct 7, 2021
1 parent 2dde3f3 commit 381f354
Show file tree
Hide file tree
Showing 26 changed files with 55 additions and 75 deletions.
3 changes: 1 addition & 2 deletions tests/app/cgi-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def voila_args(notebook_directory, voila_args_extra):


async def test_cgi_using_query_parameters(http_server_client,
notebook_cgi_path, wait_for_kernel):
await wait_for_kernel()
notebook_cgi_path):
response = await http_server_client.fetch(notebook_cgi_path +
'?username=VOILA')
assert response.code == 200
Expand Down
4 changes: 2 additions & 2 deletions tests/app/config_paths_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def test_config_contents_manager(voila_app):
assert voila_app.contents_manager.use_atomic_writing is False


async def test_template(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_template(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
assert 'test_template.css' in response.body.decode('utf-8')
Expand Down
21 changes: 6 additions & 15 deletions tests/app/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import pytest
import voila.app
import asyncio


BASE_DIR = os.path.dirname(__file__)

Expand Down Expand Up @@ -33,13 +33,13 @@ def voila_args(voila_notebook, voila_args_extra, voila_config_file_paths_arg):
return [voila_notebook, voila_config_file_paths_arg] + voila_args_extra + debug_args


@pytest.fixture(params=[False, True])
def preheat_mode(request):
@pytest.fixture
def preheat_mode():
"""Fixture used to activate/deactivate pre-heat kernel mode.
All tests will be executed in two modes automatically, override
this fixture in test file if you want to run only one mode.
Override this fixture in test file if you want to activate
preheat mode.
"""
return request.param
return False


@pytest.fixture
Expand All @@ -61,12 +61,3 @@ def voila_app(voila_args, voila_config, preheat_config):
@pytest.fixture
def app(voila_app):
return voila_app.app


@pytest.fixture
def wait_for_kernel(preheat_mode):
"""Wait for kernel be heated in case of `preheat_mode = True`"""
async def inner(time=3):
if preheat_mode:
await asyncio.sleep(time)
return inner
4 changes: 2 additions & 2 deletions tests/app/cwd_subdir_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def voila_args(notebook_directory, voila_args_extra):


async def test_hello_world(
http_server_client, cwd_subdir_notebook_url, wait_for_kernel
http_server_client, cwd_subdir_notebook_url
):
await wait_for_kernel()

response = await http_server_client.fetch(cwd_subdir_notebook_url)
html_text = response.body.decode('utf-8')
assert 'check for the cwd' in html_text
4 changes: 2 additions & 2 deletions tests/app/cwd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def voila_notebook(notebook_directory):
return os.path.join(notebook_directory, 'cwd.ipynb')


async def test_template_cwd(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_template_cwd(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
html_text = response.body.decode('utf-8')
assert 'check for the cwd' in html_text
4 changes: 2 additions & 2 deletions tests/app/execute_cpp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def voila_args(notebook_directory, voila_args_extra, preheat_mode):


@pytest.mark.skipif(not TEST_XEUS_CLING, reason='opt in to avoid having to install xeus-cling')
async def test_non_existing_kernel(http_server_client, cpp_file_url, wait_for_kernel):
await wait_for_kernel()
async def test_non_existing_kernel(http_server_client, cpp_file_url):

response = await http_server_client.fetch(cpp_file_url)
assert response.code == 200
assert 'Hello Voilà, from c++' in response.body.decode('utf-8')
8 changes: 4 additions & 4 deletions tests/app/execute_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import mock


async def test_hello_world(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_hello_world(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
html_text = response.body.decode('utf-8')
Expand All @@ -21,8 +21,8 @@ async def test_hello_world(http_server_client, base_url, wait_for_kernel):
assert 'test_template.css' not in html_text, "test_template should not be the default"


async def test_no_execute_allowed(voila_app, app, http_server_client, base_url, http_server_port, wait_for_kernel):
await wait_for_kernel()
async def test_no_execute_allowed(voila_app, app, http_server_client, base_url, http_server_port):

assert voila_app.app is app
response = (await http_server_client.fetch(base_url)).body.decode('utf-8')
pattern = r"""kernelId": ["']([0-9a-zA-Z-]+)["']"""
Expand Down
4 changes: 2 additions & 2 deletions tests/app/image_inlining_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def voila_notebook(notebook_directory):
return os.path.join(notebook_directory, NOTEBOOK_PATH)


async def test_image_inlining(http_server_client, base_url, notebook_directory, wait_for_kernel):
await wait_for_kernel()
async def test_image_inlining(http_server_client, base_url, notebook_directory):

response = await http_server_client.fetch(base_url)
html_text = response.body.decode('utf-8')

Expand Down
4 changes: 2 additions & 2 deletions tests/app/kernel_death_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def preheat_mode():
return False


async def test_kernel_death(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_kernel_death(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
html_text = response.body.decode('utf-8')
assert 'raise DeadKernelError' in html_text
4 changes: 2 additions & 2 deletions tests/app/nbextensions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def voila_config_file_paths_arg():
return '--VoilaTest.config_file_paths=[%r]' % path


async def test_lists_extension(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_lists_extension(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
html_text = response.body.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/no_kernelspec_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def voila_args(notebook_directory, voila_args_extra):

async def test_non_existing_kernel(http_server_client,
non_existing_kernel_notebook,
wait_for_kernel):
await wait_for_kernel()
):

response = await http_server_client.fetch(non_existing_kernel_notebook)
assert response.code == 200
assert 'Executing without a kernelspec' in response.body.decode('utf-8')
4 changes: 2 additions & 2 deletions tests/app/no_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def voila_args(notebook_directory, voila_args_extra):


async def test_non_existing_metadata(
http_server_client, non_existing_notebook_metadata, wait_for_kernel
http_server_client, non_existing_notebook_metadata
):
await wait_for_kernel()

response = await http_server_client.fetch(non_existing_notebook_metadata)
assert response.code == 200
assert 'Executing without notebook metadata' in response.body.decode('utf-8')
4 changes: 2 additions & 2 deletions tests/app/no_strip_sources_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def voila_args_extra():
return ['--VoilaConfiguration.strip_sources=False', '--VoilaExecutor.timeout=240']


async def test_no_strip_sources(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_no_strip_sources(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
html_text = response.body.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/non_existing_kernel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def voila_args(notebook_directory, voila_args_extra):


async def test_non_existing_kernel(
http_server_client, non_existing_kernel_notebook, wait_for_kernel
http_server_client, non_existing_kernel_notebook
):
await wait_for_kernel()

response = await http_server_client.fetch(non_existing_kernel_notebook)
assert response.code == 200
assert "non-existing kernel" in response.body.decode("utf-8")
4 changes: 2 additions & 2 deletions tests/app/notebooks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def voila_args(notebook_directory, voila_args_extra):


async def test_other_comms(
http_server_client, notebook_other_comms_path, wait_for_kernel
http_server_client, notebook_other_comms_path
):
await wait_for_kernel()

response = await http_server_client.fetch(notebook_other_comms_path)
html_text = response.body.decode('utf-8')
assert 'This notebook executed' in html_text
4 changes: 2 additions & 2 deletions tests/app/preprocessor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def voila_args_extra():
return ['--template=skip_template']


async def test_markdown_preprocessor(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_markdown_preprocessor(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
html_text = response.body.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/show_traceback_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def voila_args(notebook_directory, voila_args_extra, show_tracebacks):


async def test_syntax_error(
http_server_client, notebook_show_traceback_path, show_tracebacks, wait_for_kernel
http_server_client, notebook_show_traceback_path, show_tracebacks
):
await wait_for_kernel()

response = await http_server_client.fetch(notebook_show_traceback_path)
assert response.code == 200
output = response.body.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/shutdown_kernel_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import re


async def test_shutdown_handler(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_shutdown_handler(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
html_text = response.body.decode('utf-8')
pattern = r"""kernelId": ["']([0-9a-zA-Z-]+)["']"""
Expand Down
4 changes: 2 additions & 2 deletions tests/app/syntax_error_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def voila_notebook(notebook_directory):
return os.path.join(notebook_directory, NOTEBOOK_PATH)


async def test_syntax_error(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_syntax_error(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
output = response.body.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/template_arg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def voila_args_extra():
return ['--template=test_template', '--VoilaExecutor.timeout=240']


async def test_template(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_template(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
assert 'test_template.css' in response.body.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/template_cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def voila_args_extra():
return ['--template=test_template', '--VoilaTest.template_paths=[%r, %r]' % (path_test_template, path_default), '--VoilaExecutor.timeout=240']


async def test_template_test(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_template_test(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
assert 'test_template.css' in response.body.decode('utf-8')
4 changes: 2 additions & 2 deletions tests/app/template_config_file_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def voila_args_extra():
return ['--template=test_template', '--Voila.nbconvert_template_paths=[%r, %r]' % (path_test_template, path_default), '--VoilaExecutor.timeout=240']


async def test_template_test(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_template_test(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
assert 'test_template.css' in response.body.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/template_custom_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def config(app):
return config


async def test_template(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_template(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
assert response.code == 200
assert 'test_template.css' in response.body.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/template_sanity_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def voila_args_extra(request):
return [f'--template={request.param}']


async def test_lists_extension(http_server_client, base_url, voila_app, wait_for_kernel):
await wait_for_kernel()
async def test_lists_extension(http_server_client, base_url, voila_app):

response = await http_server_client.fetch(base_url)
assert response.code == 200
html_text = response.body.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions tests/app/timeout_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def voila_args_extra():
return ['--VoilaExecutor.timeout=1', '--KernelManager.shutdown_wait_time=0.1']


async def test_timeout(http_server_client, base_url, wait_for_kernel):
await wait_for_kernel()
async def test_timeout(http_server_client, base_url):

response = await http_server_client.fetch(base_url)
html_text = response.body.decode('utf-8')
assert 'Cell execution timed out' in html_text
10 changes: 0 additions & 10 deletions tests/voila.json

This file was deleted.

0 comments on commit 381f354

Please sign in to comment.