Commit 0cc1f8dd authored by romainx's avatar romainx

nbconvert + inkscape test improvements

parent 32768af3
This diff is collapsed.
This diff is collapsed.
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import logging
LOGGER = logging.getLogger(__name__)
def test_inkscape(container):
"""Inkscape shall be installed to be able to convert SVG files."""
LOGGER.info("Test that inkscape is working by printing its version ...")
c = container.run(
tty=True, command=["start.sh", "bash", "-c", "inkscape --version"]
)
c.wait(timeout=10)
logs = c.logs(stdout=True).decode("utf-8")
LOGGER.debug(logs)
assert "Inkscape" in logs, "Inkscape not installed or not working"
......@@ -9,15 +9,17 @@ import os
LOGGER = logging.getLogger(__name__)
@pytest.mark.parametrize("format", ["html", "pdf"])
def test_nbconvert(container, format):
@pytest.mark.parametrize("test_file, output_format,", [
("notebook_math", "pdf"), ("notebook_math", "html"),
("notebook_svg", "pdf"), ("notebook_svg", "html"),
])
def test_nbconvert(container, test_file, output_format):
"""Check if nbconvert is able to convert a notebook file"""
host_data_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
cont_data_dir = "/home/jovyan/data"
test_file = "notebook1"
output_dir = "/tmp"
LOGGER.info(f"Test that an example notebook can be converted to {format.upper()} ...")
command = f"jupyter nbconvert {cont_data_dir}/{test_file}.ipynb --output-dir {output_dir} --to {format}"
LOGGER.info(f"Test that the example notebook {test_file} can be converted to {output_format.upper()} ...")
command = f"jupyter nbconvert {cont_data_dir}/{test_file}.ipynb --output-dir {output_dir} --to {output_format}"
c = container.run(
volumes={host_data_dir: {"bind": cont_data_dir, "mode": "ro"}},
tty=True,
......@@ -27,5 +29,5 @@ def test_nbconvert(container, format):
assert rv == 0 or rv["StatusCode"] == 0, f"Command {command} failed"
logs = c.logs(stdout=True).decode("utf-8")
LOGGER.debug(logs)
expected_file = f"{output_dir}/{test_file}.{format}"
expected_file = f"{output_dir}/{test_file}.{output_format}"
assert expected_file in logs, f"Expected file {expected_file} not generated"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment