"""Tests for the svg2pdf preprocessor""" # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. from IPython.testing import decorators as dec from IPython.nbformat import v4 as nbformat from .base import PreprocessorTestsBase from ..svg2pdf import SVG2PDFPreprocessor class Testsvg2pdf(PreprocessorTestsBase): """Contains test functions for svg2pdf.py""" simple_svg = """ """ def build_notebook(self): """Build a reveal slides notebook in memory for use with tests. Overrides base in PreprocessorTestsBase""" outputs = [nbformat.new_output(output_type="image/svg+xml", output_svg=self.simple_svg)] slide_metadata = {'slideshow' : {'slide_type': 'slide'}} subslide_metadata = {'slideshow' : {'slide_type': 'subslide'}} cells=[nbformat.new_code_cell(source="", execution_count=1, outputs=outputs)] return nbformat.new_notebook(cells=cells) def build_preprocessor(self): """Make an instance of a preprocessor""" preprocessor = SVG2PDFPreprocessor() preprocessor.enabled = True return preprocessor def test_constructor(self): """Can a SVG2PDFPreprocessor be constructed?""" self.build_preprocessor() @dec.onlyif_cmds_exist('inkscape') def test_output(self): """Test the output of the SVG2PDFPreprocessor""" nb = self.build_notebook() res = self.build_resources() preprocessor = self.build_preprocessor() nb, res = preprocessor(nb, res) self.assertIn('application/pdf', nb.cells[0].outputs[0])