Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cloudooo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cloudooo
Commits
db5115d8
Commit
db5115d8
authored
Jun 27, 2016
by
Tristan Cavelier
Committed by
Cédric Le Ninivin
Jun 27, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wkhtmltopdf: reduce test code
parent
e86de962
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
17 deletions
+10
-17
cloudooo/handler/wkhtmltopdf/tests/testWkhtmltopdfHandler.py
cloudooo/handler/wkhtmltopdf/tests/testWkhtmltopdfHandler.py
+10
-17
No files found.
cloudooo/handler/wkhtmltopdf/tests/testWkhtmltopdfHandler.py
View file @
db5115d8
...
...
@@ -37,38 +37,31 @@ class TestHandler(HandlerTestCase):
def
afterSetUp
(
self
):
self
.
kw
=
dict
(
env
=
dict
(
PATH
=
self
.
env_path
))
def
testConvertHtmlWithPngDataUrlToPdf
(
self
):
"""Test conversion of html with png data url to pdf"""
html_file
=
open
(
"data/test_with_png_dataurl.html"
).
read
()
def
_testBase
(
self
,
html_path
,
**
conversion_kw
):
html_file
=
open
(
html_path
).
read
()
handler
=
Handler
(
self
.
tmp_url
,
html_file
,
"html"
,
**
self
.
kw
)
pdf_file
=
handler
.
convert
(
"pdf"
)
pdf_file
=
handler
.
convert
(
"pdf"
,
**
conversion_kw
)
mime
=
magic
.
Magic
(
mime
=
True
)
pdf_mimetype
=
mime
.
from_buffer
(
pdf_file
)
self
.
assertEquals
(
"application/pdf"
,
pdf_mimetype
)
def
testConvertHtmlWithPngDataUrlToPdf
(
self
):
"""Test conversion of html with png data url to pdf"""
self
.
_testBase
(
"data/test_with_png_dataurl.html"
)
def
testConvertHtmlWithScriptToPdf
(
self
):
"""Test conversion of html with script to pdf"""
html_file
=
open
(
"data/test_with_script.html"
).
read
()
handler
=
Handler
(
self
.
tmp_url
,
html_file
,
"html"
,
**
self
.
kw
)
pdf_file
=
handler
.
convert
(
"pdf"
)
mime
=
magic
.
Magic
(
mime
=
True
)
pdf_mimetype
=
mime
.
from_buffer
(
pdf_file
)
self
.
assertEquals
(
"application/pdf"
,
pdf_mimetype
)
self
.
_testBase
(
"data/test_with_script.html"
)
# TODO: def testConvertHtmlWithHeaderAndFooter(self):
def
testConvertHtmlWithTableOfContent
(
self
):
"""Test conversion of html with an additional table of content"""
html_file
=
open
(
"data/test_with_toc.html"
).
read
()
handler
=
Handler
(
self
.
tmp_url
,
html_file
,
"html"
,
**
self
.
kw
)
pdf_file
=
handler
.
convert
(
"pdf"
,
self
.
_testBase
(
"data/test_with_toc.html"
,
toc
=
True
,
xsl_style_sheet_data
=
b64encode
(
open
(
"data/test_toc.xsl"
).
read
()),
)
mime
=
magic
.
Magic
(
mime
=
True
)
pdf_mimetype
=
mime
.
from_buffer
(
pdf_file
)
self
.
assertEquals
(
"application/pdf"
,
pdf_mimetype
)
# XXX how to check for table of content presence ?
def
testsetMetadata
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment