Show More
@@ -0,0 +1,82 b'' | |||
|
1 | """ | |
|
2 | Module with tests for the svg2pdf transformer | |
|
3 | """ | |
|
4 | ||
|
5 | #----------------------------------------------------------------------------- | |
|
6 | # Copyright (c) 2013, the IPython Development Team. | |
|
7 | # | |
|
8 | # Distributed under the terms of the Modified BSD License. | |
|
9 | # | |
|
10 | # The full license is in the file COPYING.txt, distributed with this software. | |
|
11 | #----------------------------------------------------------------------------- | |
|
12 | ||
|
13 | #----------------------------------------------------------------------------- | |
|
14 | # Imports | |
|
15 | #----------------------------------------------------------------------------- | |
|
16 | ||
|
17 | from IPython.testing import decorators as dec | |
|
18 | from IPython.nbformat import current as nbformat | |
|
19 | ||
|
20 | from .base import TransformerTestsBase | |
|
21 | from ..svg2pdf import SVG2PDFTransformer | |
|
22 | ||
|
23 | ||
|
24 | #----------------------------------------------------------------------------- | |
|
25 | # Class | |
|
26 | #----------------------------------------------------------------------------- | |
|
27 | ||
|
28 | class Testsvg2pdf(TransformerTestsBase): | |
|
29 | """Contains test functions for svg2pdf.py""" | |
|
30 | ||
|
31 | simple_svg = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
|
32 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | |
|
33 | <svg | |
|
34 | xmlns:svg="http://www.w3.org/2000/svg" | |
|
35 | xmlns="http://www.w3.org/2000/svg" | |
|
36 | version="1.0" | |
|
37 | x="0.00000000" | |
|
38 | y="0.00000000" | |
|
39 | width="500.00000" | |
|
40 | height="500.00000" | |
|
41 | id="svg2"> | |
|
42 | <defs | |
|
43 | id="defs4" /> | |
|
44 | <g | |
|
45 | id="layer1"> | |
|
46 | <rect | |
|
47 | width="300.00000" | |
|
48 | height="300.00000" | |
|
49 | x="100.00000" | |
|
50 | y="100.00000" | |
|
51 | 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" | |
|
52 | id="rect5719" /> | |
|
53 | </g> | |
|
54 | </svg>""" | |
|
55 | ||
|
56 | def build_notebook(self): | |
|
57 | """Build a reveal slides notebook in memory for use with tests. | |
|
58 | Overrides base in TransformerTestsBase""" | |
|
59 | ||
|
60 | outputs = [nbformat.new_output(output_type="svg", output_svg=self.simple_svg)] | |
|
61 | ||
|
62 | slide_metadata = {'slideshow' : {'slide_type': 'slide'}} | |
|
63 | subslide_metadata = {'slideshow' : {'slide_type': 'subslide'}} | |
|
64 | ||
|
65 | cells=[nbformat.new_code_cell(input="", prompt_number=1, outputs=outputs)] | |
|
66 | worksheets = [nbformat.new_worksheet(name="worksheet1", cells=cells)] | |
|
67 | ||
|
68 | return nbformat.new_notebook(name="notebook1", worksheets=worksheets) | |
|
69 | ||
|
70 | ||
|
71 | def test_constructor(self): | |
|
72 | """Can a SVG2PDFTransformer be constructed?""" | |
|
73 | transformer = SVG2PDFTransformer() | |
|
74 | transformer.enabled = True | |
|
75 | return transformer | |
|
76 | ||
|
77 | ||
|
78 | @dec.onlyif_cmds_exist('inkscape') | |
|
79 | def test_output(self): | |
|
80 | """Test the output of the SVG2PDFTransformer""" | |
|
81 | nb, res = self.test_constructor()(self.build_notebook(), self.build_resources()) | |
|
82 | assert 'svg' in nb.worksheets[0].cells[0].outputs[0] |
General Comments 0
You need to be logged in to leave comments.
Login now