diff --git a/minimal-notebook/test/data/Jupyter_logo.svg b/minimal-notebook/test/data/Jupyter_logo.svg new file mode 100644 index 00000000..ab255087 --- /dev/null +++ b/minimal-notebook/test/data/Jupyter_logo.svg @@ -0,0 +1,90 @@ + +Group.svg +Created using Figma 0.90 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/minimal-notebook/test/data/notebook1.ipynb b/minimal-notebook/test/data/notebook_math.ipynb similarity index 100% rename from minimal-notebook/test/data/notebook1.ipynb rename to minimal-notebook/test/data/notebook_math.ipynb diff --git a/minimal-notebook/test/data/notebook_svg.ipynb b/minimal-notebook/test/data/notebook_svg.ipynb new file mode 100644 index 00000000..e26997e2 --- /dev/null +++ b/minimal-notebook/test/data/notebook_svg.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "Group.svg\n", + "Created using Figma 0.90\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "from IPython.display import SVG, display\n", + "\n", + "display(SVG(filename=\"Jupyter_logo.svg\"))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.6" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/minimal-notebook/test/test_inkscape.py b/minimal-notebook/test/test_inkscape.py new file mode 100644 index 00000000..e8f50e2c --- /dev/null +++ b/minimal-notebook/test/test_inkscape.py @@ -0,0 +1,18 @@ +# 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" diff --git a/minimal-notebook/test/test_nbconvert.py b/minimal-notebook/test/test_nbconvert.py index 5dc61f0d..a9f3093b 100644 --- a/minimal-notebook/test/test_nbconvert.py +++ b/minimal-notebook/test/test_nbconvert.py @@ -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"