Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Gabriel Monnerat
erp5
Commits
9ac96204
Commit
9ac96204
authored
May 27, 2021
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dms: test more cases of converting PDFs to images
parent
1d0aeccb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
+38
-3
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
...s/TestTemplateItem/portal_components/test.erp5.testDms.py
+38
-3
No files found.
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
View file @
9ac96204
...
...
@@ -1249,16 +1249,51 @@ class TestDocument(TestDocumentMixin):
self
.
assert_
(
'I use reference to look up TEST'
in
document
.
SearchableText
())
def
test_PDFTo
Image
(
self
):
def
test_PDFTo
Png
(
self
):
upload_file
=
makeFileUpload
(
'REF-en-001.pdf'
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
_
,
image_data
=
document
.
convert
(
format
=
'png'
,
mime
,
image_data
=
document
.
convert
(
format
=
'png'
,
frame
=
0
,
display
=
'thumbnail'
)
self
.
assertEqual
(
mime
,
'image/png'
)
# it's a valid PNG
self
.
assertEqual
(
'PNG'
,
image_data
[
1
:
4
])
self
.
assertEqual
(
image_data
[
1
:
4
],
'PNG'
)
def
test_PDFToJpg
(
self
):
upload_file
=
makeFileUpload
(
'REF-en-001.pdf'
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
mime
,
image_data
=
document
.
convert
(
format
=
'jpg'
,
frame
=
0
,
display
=
'thumbnail'
)
self
.
assertEqual
(
mime
,
'image/jpeg'
)
self
.
assertEqual
(
image_data
[
6
:
10
],
'JFIF'
)
def
test_PDFToGif
(
self
):
upload_file
=
makeFileUpload
(
'REF-en-001.pdf'
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
mime
,
image_data
=
document
.
convert
(
format
=
'gif'
,
frame
=
0
,
display
=
'thumbnail'
)
self
.
assertEqual
(
mime
,
'image/gif'
)
self
.
assertEqual
(
image_data
[
0
:
4
],
'GIF8'
)
def
test_PDFToTiff
(
self
):
upload_file
=
makeFileUpload
(
'REF-en-001.pdf'
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
mime
,
image_data
=
document
.
convert
(
format
=
'tiff'
,
frame
=
0
,
display
=
'thumbnail'
)
self
.
assertEqual
(
mime
,
'image/tiff'
)
self
.
assertIn
(
image_data
[
0
:
2
],
(
'II'
,
'MM'
))
def
test_PDF_content_information
(
self
):
upload_file
=
makeFileUpload
(
'REF-en-001.pdf'
)
...
...
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