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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
6ad6fe70
Commit
6ad6fe70
authored
May 20, 2024
by
Jérome Perrin
Committed by
Arnaud Fontaine
Jul 15, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testDms: add a test for PDF->HTML conversion
parent
c7c6c10f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
...s/TestTemplateItem/portal_components/test.erp5.testDms.py
+17
-6
No files found.
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
View file @
6ad6fe70
...
@@ -53,14 +53,14 @@ from subprocess import Popen, PIPE
...
@@ -53,14 +53,14 @@ from subprocess import Popen, PIPE
from
unittest
import
expectedFailure
from
unittest
import
expectedFailure
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
FileUpload
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
DummyLocalizer
from
Products.ERP5Type.tests.utils
import
DummyLocalizer
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
from
Products.ERP5Type.tests.utils
import
FileUpload
from
Products.ERP5OOo.OOoUtils
import
OOoBuilder
from
Products.ERP5OOo.OOoUtils
import
OOoBuilder
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
erp5.component.document.Document
import
NotConvertedError
from
erp5.component.document.Document
import
NotConvertedError
from
Products.ERP5Form.PreferenceTool
import
Priority
from
Products.ERP5Form.PreferenceTool
import
Priority
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.Globals
import
get_request
from
Products.ERP5Type.Globals
import
get_request
import
os
import
os
from
threading
import
Thread
from
threading
import
Thread
...
@@ -1324,6 +1324,17 @@ class TestDocument(TestDocumentMixin):
...
@@ -1324,6 +1324,17 @@ class TestDocument(TestDocumentMixin):
self
.
assertIn
(
'I use reference to look up TEST'
,
self
.
assertIn
(
'I use reference to look up TEST'
,
document
.
SearchableText
())
document
.
SearchableText
())
def
test_PDFToHTML
(
self
):
upload_file
=
self
.
makeFileUpload
(
'REF-en-001.pdf'
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
for
_
in
(
'empty_cache'
,
'cache'
):
mime
,
html
=
document
.
convert
(
format
=
'html'
)
self
.
assertEqual
(
mime
,
'text/html'
)
self
.
assertIn
(
'TEST'
,
html
)
self
.
tic
()
def
test_PDFToPng
(
self
):
def
test_PDFToPng
(
self
):
upload_file
=
self
.
makeFileUpload
(
'REF-en-001.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'REF-en-001.pdf'
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
...
@@ -1697,7 +1708,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1697,7 +1708,7 @@ class TestDocument(TestDocumentMixin):
def
test_HTML_to_PDF
(
self
):
def
test_HTML_to_PDF
(
self
):
web_page
=
self
.
portal
.
web_page_module
.
newContent
(
web_page
=
self
.
portal
.
web_page_module
.
newContent
(
portal_type
=
'Web Page'
,
portal_type
=
'Web Page'
,
text_content
=
u
'<p>héhé</p>'
text_content
=
'<p>héhé</p>'
)
)
# ERP5 convert API
# ERP5 convert API
_
,
pdf_data
=
web_page
.
convert
(
'pdf'
)
_
,
pdf_data
=
web_page
.
convert
(
'pdf'
)
...
@@ -1705,19 +1716,19 @@ class TestDocument(TestDocumentMixin):
...
@@ -1705,19 +1716,19 @@ class TestDocument(TestDocumentMixin):
portal_type
=
'PDF'
,
portal_type
=
'PDF'
,
data
=
pdf_data
data
=
pdf_data
)
)
self
.
assertEqual
(
pdf
.
asText
().
strip
(),
u
'héhé'
)
self
.
assertEqual
(
pdf
.
asText
().
strip
(),
'héhé'
)
# portal_transforms convert API
# portal_transforms convert API
pdf_data
=
self
.
portal
.
portal_transforms
.
convertTo
(
pdf_data
=
self
.
portal
.
portal_transforms
.
convertTo
(
'application/pdf'
,
'application/pdf'
,
orig
=
u
'<p>héhé</p>'
,
orig
=
'<p>héhé</p>'
,
context
=
self
.
portal
,
context
=
self
.
portal
,
mimetype
=
'test/html'
).
getData
()
mimetype
=
'test/html'
).
getData
()
pdf
=
self
.
portal
.
document_module
.
newContent
(
pdf
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
portal_type
=
'PDF'
,
data
=
pdf_data
data
=
pdf_data
)
)
self
.
assertEqual
(
pdf
.
asText
().
strip
(),
u
'héhé'
)
self
.
assertEqual
(
pdf
.
asText
().
strip
(),
'héhé'
)
def
test_addContributorToDocument
(
self
):
def
test_addContributorToDocument
(
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