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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
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
Hide 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):
...
@@ -37,38 +37,31 @@ class TestHandler(HandlerTestCase):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
self
.
kw
=
dict
(
env
=
dict
(
PATH
=
self
.
env_path
))
self
.
kw
=
dict
(
env
=
dict
(
PATH
=
self
.
env_path
))
def
testConvertHtmlWithPngDataUrlToPdf
(
self
):
def
_testBase
(
self
,
html_path
,
**
conversion_kw
):
"""Test conversion of html with png data url to pdf"""
html_file
=
open
(
html_path
).
read
()
html_file
=
open
(
"data/test_with_png_dataurl.html"
).
read
()
handler
=
Handler
(
self
.
tmp_url
,
html_file
,
"html"
,
**
self
.
kw
)
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
)
mime
=
magic
.
Magic
(
mime
=
True
)
pdf_mimetype
=
mime
.
from_buffer
(
pdf_file
)
pdf_mimetype
=
mime
.
from_buffer
(
pdf_file
)
self
.
assertEquals
(
"application/pdf"
,
pdf_mimetype
)
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
):
def
testConvertHtmlWithScriptToPdf
(
self
):
"""Test conversion of html with script to pdf"""
"""Test conversion of html with script to pdf"""
html_file
=
open
(
"data/test_with_script.html"
).
read
()
self
.
_testBase
(
"data/test_with_script.html"
)
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
)
# TODO: def testConvertHtmlWithHeaderAndFooter(self):
# TODO: def testConvertHtmlWithHeaderAndFooter(self):
def
testConvertHtmlWithTableOfContent
(
self
):
def
testConvertHtmlWithTableOfContent
(
self
):
"""Test conversion of html with an additional table of content"""
"""Test conversion of html with an additional table of content"""
html_file
=
open
(
"data/test_with_toc.html"
).
read
()
self
.
_testBase
(
handler
=
Handler
(
self
.
tmp_url
,
html_file
,
"html"
,
**
self
.
kw
)
"data/test_with_toc.html"
,
pdf_file
=
handler
.
convert
(
"pdf"
,
toc
=
True
,
toc
=
True
,
xsl_style_sheet_data
=
b64encode
(
open
(
"data/test_toc.xsl"
).
read
()),
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 ?
# XXX how to check for table of content presence ?
def
testsetMetadata
(
self
):
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