Show More
@@ -1,76 +1,73 | |||
|
1 | 1 | """Tests for the svg2pdf preprocessor""" |
|
2 | 2 | |
|
3 | 3 | # Copyright (c) IPython Development Team. |
|
4 | 4 | # Distributed under the terms of the Modified BSD License. |
|
5 | 5 | |
|
6 | 6 | from IPython.testing import decorators as dec |
|
7 | 7 | from IPython.nbformat import v4 as nbformat |
|
8 | 8 | |
|
9 | 9 | from .base import PreprocessorTestsBase |
|
10 | 10 | from ..svg2pdf import SVG2PDFPreprocessor |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | class Testsvg2pdf(PreprocessorTestsBase): |
|
14 | 14 | """Contains test functions for svg2pdf.py""" |
|
15 | 15 | |
|
16 | 16 | simple_svg = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
|
17 | 17 | <!-- Created with Inkscape (http://www.inkscape.org/) --> |
|
18 | 18 | <svg |
|
19 | 19 | xmlns:svg="http://www.w3.org/2000/svg" |
|
20 | 20 | xmlns="http://www.w3.org/2000/svg" |
|
21 | 21 | version="1.0" |
|
22 | 22 | x="0.00000000" |
|
23 | 23 | y="0.00000000" |
|
24 | 24 | width="500.00000" |
|
25 | 25 | height="500.00000" |
|
26 | 26 | id="svg2"> |
|
27 | 27 | <defs |
|
28 | 28 | id="defs4" /> |
|
29 | 29 | <g |
|
30 | 30 | id="layer1"> |
|
31 | 31 | <rect |
|
32 | 32 | width="300.00000" |
|
33 | 33 | height="300.00000" |
|
34 | 34 | x="100.00000" |
|
35 | 35 | y="100.00000" |
|
36 | 36 | style="opacity:1.0000000;fill:none;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:8.0000000;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-dashoffset:0.00000000;stroke-opacity:1.0000000" |
|
37 | 37 | id="rect5719" /> |
|
38 | 38 | </g> |
|
39 | 39 | </svg>""" |
|
40 | 40 | |
|
41 | 41 | def build_notebook(self): |
|
42 | 42 | """Build a reveal slides notebook in memory for use with tests. |
|
43 | 43 | Overrides base in PreprocessorTestsBase""" |
|
44 | 44 | |
|
45 | 45 | outputs = [nbformat.new_output(output_type='display_data', |
|
46 | 46 | data={'image/svg+xml':self.simple_svg}) |
|
47 | 47 | ] |
|
48 | ||
|
49 | slide_metadata = {'slideshow' : {'slide_type': 'slide'}} | |
|
50 | subslide_metadata = {'slideshow' : {'slide_type': 'subslide'}} | |
|
51 | 48 | |
|
52 | 49 | cells=[nbformat.new_code_cell(source="", execution_count=1, outputs=outputs)] |
|
53 | 50 | |
|
54 | 51 | return nbformat.new_notebook(cells=cells) |
|
55 | 52 | |
|
56 | 53 | |
|
57 | 54 | def build_preprocessor(self): |
|
58 | 55 | """Make an instance of a preprocessor""" |
|
59 | 56 | preprocessor = SVG2PDFPreprocessor() |
|
60 | 57 | preprocessor.enabled = True |
|
61 | 58 | return preprocessor |
|
62 | 59 | |
|
63 | 60 | |
|
64 | 61 | def test_constructor(self): |
|
65 | 62 | """Can a SVG2PDFPreprocessor be constructed?""" |
|
66 | 63 | self.build_preprocessor() |
|
67 | 64 | |
|
68 | 65 | |
|
69 | 66 | @dec.onlyif_cmds_exist('inkscape') |
|
70 | 67 | def test_output(self): |
|
71 | 68 | """Test the output of the SVG2PDFPreprocessor""" |
|
72 | 69 | nb = self.build_notebook() |
|
73 | 70 | res = self.build_resources() |
|
74 | 71 | preprocessor = self.build_preprocessor() |
|
75 | 72 | nb, res = preprocessor(nb, res) |
|
76 | 73 | self.assertIn('application/pdf', nb.cells[0].outputs[0].data) |
General Comments 0
You need to be logged in to leave comments.
Login now