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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
erp5
Commits
58b111f2
Commit
58b111f2
authored
Jan 28, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testDms
parent
a7bced74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
23 deletions
+17
-23
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
...s/TestTemplateItem/portal_components/test.erp5.testDms.py
+17
-23
No files found.
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
View file @
58b111f2
...
...
@@ -46,9 +46,9 @@
"""
from
__future__
import
print_function
import
io
import
unittest
import
time
from
six.moves
import
cStringIO
as
StringIO
from
subprocess
import
Popen
,
PIPE
from
unittest
import
expectedFailure
...
...
@@ -1467,7 +1467,7 @@ class TestDocument(TestDocumentMixin):
repeat_watermark
=
False
)
# this looks like a pdf
self
.
assertTrue
(
watermarked_data
.
startswith
(
'%PDF-1.3'
))
self
.
assertTrue
(
watermarked_data
.
startswith
(
b
'%PDF-1.3'
))
# and ERP5 can make a PDF Document out of it
watermarked_document
=
self
.
portal
.
document_module
.
newContent
(
...
...
@@ -1487,7 +1487,7 @@ class TestDocument(TestDocumentMixin):
watermark_data
=
watermark_document
.
getData
(),
repeat_watermark
=
True
)
self
.
assertTrue
(
watermarked_data
.
startswith
(
'%PDF-1.3'
))
self
.
assertTrue
(
watermarked_data
.
startswith
(
b
'%PDF-1.3'
))
watermarked_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
data
=
watermarked_data
)
...
...
@@ -1506,7 +1506,7 @@ class TestDocument(TestDocumentMixin):
repeat_watermark
=
False
,
watermark_start_page
=
1
)
# This is 0 based.
self
.
assertTrue
(
watermarked_data
.
startswith
(
'%PDF-1.3'
))
self
.
assertTrue
(
watermarked_data
.
startswith
(
b
'%PDF-1.3'
))
watermarked_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
data
=
watermarked_data
)
...
...
@@ -1566,7 +1566,7 @@ class TestDocument(TestDocumentMixin):
self
.
assertEqual
(
'Image'
,
document
.
getPortalType
())
resized_image
=
document
.
convert
(
format
=
'png'
,
display
=
'small'
)[
1
]
identify_output
=
Popen
([
'identify'
,
'-verbose'
,
'-'
],
stdin
=
PIPE
,
stdout
=
PIPE
).
communicate
(
resized_image
)[
0
]
self
.
assertNotIn
(
'1-bit'
,
identify_output
)
self
.
assertNotIn
(
b
'1-bit'
,
identify_output
)
self
.
assertEqual
(
'ERP5 is a free software.'
,
document
.
asText
())
def
test_Base_showFoundText
(
self
):
...
...
@@ -1740,7 +1740,7 @@ class TestDocument(TestDocumentMixin):
module
=
self
.
portal
.
getDefaultModule
(
web_page_portal_type
)
web_page
=
module
.
newContent
(
portal_type
=
web_page_portal_type
)
html_content
=
"""<html>
html_content
=
u
"""<html>
<head>
<meta http-equiv="refresh" content="5;url=http://example.com/"/>
<meta http-equiv="Set-Cookie" content=""/>
...
...
@@ -1766,9 +1766,7 @@ class TestDocument(TestDocumentMixin):
</body>
</html>
"""
if
six
.
PY2
:
html_content
=
html_content
.
decode
(
'utf-8'
).
encode
(
'iso-8859-1'
)
html_content
=
html_content
.
encode
(
'iso-8859-1'
)
# content encoded into another codec
# than utf-8 comes from necessarily an external file
# (Ingestion, or FileField), not from user interface
...
...
@@ -1777,12 +1775,8 @@ class TestDocument(TestDocumentMixin):
# as it is done in reality
# Mimic the behaviour of a FileUpload from WebPage_view
file_like
=
StringIO
()
file_like
.
write
(
html_content
)
setattr
(
file_like
,
'filename'
,
'something.htm'
)
if
six
.
PY3
:
from
io
import
BytesIO
file_like
=
BytesIO
(
file_like
.
getvalue
().
encode
())
file_like
=
io
.
BytesIO
(
html_content
)
file_like
.
filename
=
'something.htm'
web_page
.
edit
(
file
=
file_like
)
# run conversion to base format
self
.
tic
()
...
...
@@ -2074,11 +2068,11 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
self
.
assertEqual
(
document
.
asText
(),
'ERP5 is a free software.'
)
def
test_broken_pdf_asText
(
self
):
class
StringIOWithFilename
(
String
IO
):
class
BytesIOWithFilename
(
io
.
Bytes
IO
):
filename
=
'broken.pdf'
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
file
=
StringIOWithFilename
(
'broken'
))
file
=
BytesIOWithFilename
(
b
'broken'
))
self
.
assertEqual
(
document
.
asText
(),
''
)
self
.
tic
()
# no activity failure
...
...
@@ -2087,7 +2081,7 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
pdf_writer
=
PyPDF2
.
PdfFileWriter
()
pdf_writer
.
addPage
(
pdf_reader
.
getPage
(
0
))
pdf_writer
.
encrypt
(
'secret'
)
encrypted_pdf_stream
=
String
IO
()
encrypted_pdf_stream
=
io
.
Bytes
IO
()
pdf_writer
.
write
(
encrypted_pdf_stream
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
...
...
@@ -2169,12 +2163,12 @@ return 1
for
credential
in
[
'ERP5TypeTestCase:'
,
'zope_user:'
]:
response
=
self
.
publish
(
'%s/%s'
%
(
document
.
getPath
(),
object_url
),
basic
=
credential
)
self
.
assertIn
(
'200 OK'
,
response
.
getOutput
())
self
.
assertIn
(
b
'200 OK'
,
response
.
getOutput
())
# OOod produced HTML navigation, test it
self
.
assertIn
(
'First page'
,
response
.
getBody
())
self
.
assertIn
(
'Back'
,
response
.
getBody
())
self
.
assertIn
(
'Continue'
,
response
.
getBody
())
self
.
assertIn
(
'Last page'
,
response
.
getBody
())
self
.
assertIn
(
b
'First page'
,
response
.
getBody
())
self
.
assertIn
(
b
'Back'
,
response
.
getBody
())
self
.
assertIn
(
b
'Continue'
,
response
.
getBody
())
self
.
assertIn
(
b
'Last page'
,
response
.
getBody
())
def
test_getTargetFormatItemList
(
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