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
Carlos Ramos Carreño
erp5
Commits
5afebc71
Commit
5afebc71
authored
Jan 28, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testDms
parent
43d8c9ce
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
212 additions
and
207 deletions
+212
-207
bt5/erp5_discussion/TestTemplateItem/portal_components/test.erp5.testERP5Discussion.py
...ateItem/portal_components/test.erp5.testERP5Discussion.py
+4
-5
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
...s/TestTemplateItem/portal_components/test.erp5.testDms.py
+169
-163
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testOOoConversionCache.py
...tem/portal_components/test.erp5.testOOoConversionCache.py
+12
-12
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testOOoConversionServerRetry.py
...rtal_components/test.erp5.testOOoConversionServerRetry.py
+5
-6
bt5/erp5_dms_conversion_catalog/TestTemplateItem/portal_components/test.erp5.testDmsWithPreConversion.py
...m/portal_components/test.erp5.testDmsWithPreConversion.py
+3
-3
bt5/erp5_km/TestTemplateItem/portal_components/test.erp5.testKM.py
...km/TestTemplateItem/portal_components/test.erp5.testKM.py
+9
-8
bt5/erp5_pdf_merge/TestTemplateItem/portal_components/test.erp5.testERP5PDFMerge.py
...plateItem/portal_components/test.erp5.testERP5PDFMerge.py
+6
-6
bt5/erp5_run_my_doc/TestTemplateItem/portal_components/test.erp5.testRunMyDoc.py
...tTemplateItem/portal_components/test.erp5.testRunMyDoc.py
+4
-4
No files found.
bt5/erp5_discussion/TestTemplateItem/portal_components/test.erp5.testERP5Discussion.py
View file @
5afebc71
...
@@ -31,11 +31,10 @@
...
@@ -31,11 +31,10 @@
import
unittest
import
unittest
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
erp5.component.test.testDms
import
DocumentUploadTestCase
from
erp5.component.test.testDms
import
makeFileUpload
class
TestERP5Discussion
(
ERP5Type
TestCase
):
class
TestERP5Discussion
(
DocumentUpload
TestCase
):
"""Test for erp5_discussion business template.
"""Test for erp5_discussion business template.
"""
"""
...
@@ -143,7 +142,7 @@ class TestERP5Discussion(ERP5TypeTestCase):
...
@@ -143,7 +142,7 @@ class TestERP5Discussion(ERP5TypeTestCase):
self
.
assertEqual
(
0
,
len
(
attachment_list
))
self
.
assertEqual
(
0
,
len
(
attachment_list
))
# check attachment creation
# check attachment creation
file_
=
makeFileUpload
(
'TEST-en-002.doc'
)
file_
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
)
web_section1
.
WebSection_createNewDiscussionThread
(
'test1-new-with-attachment'
,
'test1 body'
,
file
=
file_
)
web_section1
.
WebSection_createNewDiscussionThread
(
'test1-new-with-attachment'
,
'test1 body'
,
file
=
file_
)
discussion_thread
,
=
[
x
for
x
in
self
.
portal
.
discussion_thread_module
.
objectValues
()
\
discussion_thread
,
=
[
x
for
x
in
self
.
portal
.
discussion_thread_module
.
objectValues
()
\
if
x
.
getId
()
not
in
discussion_thread_id_set
]
if
x
.
getId
()
not
in
discussion_thread_id_set
]
...
@@ -240,7 +239,7 @@ class TestERP5Discussion(ERP5TypeTestCase):
...
@@ -240,7 +239,7 @@ class TestERP5Discussion(ERP5TypeTestCase):
web_site_value
=
self
.
portal
.
web_site_module
.
newContent
(
portal_type
=
'Web Site'
)
web_site_value
=
self
.
portal
.
web_site_module
.
newContent
(
portal_type
=
'Web Site'
)
web_section_value
=
web_site_value
.
newContent
(
portal_type
=
'Web Section'
)
web_section_value
=
web_site_value
.
newContent
(
portal_type
=
'Web Section'
)
file_
=
makeFileUpload
(
'simple.csv'
)
file_
=
self
.
makeFileUpload
(
'simple.csv'
)
web_section_value
.
WebSection_createNewDiscussionThread
(
web_section_value
.
WebSection_createNewDiscussionThread
(
"Thread Title"
,
"Thread Title"
,
"Post Content"
,
"Post Content"
,
...
...
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testDms.py
View file @
5afebc71
...
@@ -46,13 +46,12 @@
...
@@ -46,13 +46,12 @@
"""
"""
from
__future__
import
print_function
from
__future__
import
print_function
import
io
import
unittest
import
unittest
import
time
import
time
from
six.moves
import
cStringIO
as
StringIO
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
from
unittest
import
expectedFailure
from
unittest
import
expectedFailure
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
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
FileUpload
from
Products.ERP5Type.tests.utils
import
DummyLocalizer
from
Products.ERP5Type.tests.utils
import
DummyLocalizer
...
@@ -88,20 +87,25 @@ REFERENCE_REGULAR_EXPRESSION = "(?P<reference>[A-Z]{3,10})(-(?P<language>[a-z]{2
...
@@ -88,20 +87,25 @@ REFERENCE_REGULAR_EXPRESSION = "(?P<reference>[A-Z]{3,10})(-(?P<language>[a-z]{2
def
makeFilePath
(
name
):
def
makeFilePath
(
name
):
return
os
.
path
.
join
(
TEST_FILES_HOME
,
name
)
return
os
.
path
.
join
(
TEST_FILES_HOME
,
name
)
def
makeFileUpload
(
name
,
as_name
=
None
):
def
getFileSize
(
name
):
path
=
makeFilePath
(
name
)
with
open
(
path
,
"rb"
)
as
f
:
return
len
(
f
.
read
())
class
DocumentUploadTestCase
(
ERP5TypeTestCase
):
def
makeFileUpload
(
self
,
name
,
as_name
=
None
):
if
as_name
is
None
:
if
as_name
is
None
:
as_name
=
name
as_name
=
name
path
=
makeFilePath
(
name
)
path
=
makeFilePath
(
name
)
return
FileUpload
(
path
,
as_name
)
fu
=
FileUpload
(
path
,
as_name
)
self
.
addCleanup
(
fu
.
close
)
return
fu
def
getFileSize
(
name
):
path
=
makeFilePath
(
name
)
f
=
open
(
path
,
"r"
)
file_size
=
len
(
f
.
read
())
f
.
close
()
return
file_size
class
TestDocumentMixin
(
ERP5Type
TestCase
):
class
TestDocumentMixin
(
DocumentUpload
TestCase
):
business_template_list
=
[
'erp5_core_proxy_field_legacy'
,
business_template_list
=
[
'erp5_core_proxy_field_legacy'
,
'erp5_jquery'
,
'erp5_jquery'
,
...
@@ -185,6 +189,7 @@ class TestDocumentMixin(ERP5TypeTestCase):
...
@@ -185,6 +189,7 @@ class TestDocumentMixin(ERP5TypeTestCase):
doc_module
.
manage_delObjects
(
list
(
doc_module
.
objectIds
()))
doc_module
.
manage_delObjects
(
list
(
doc_module
.
objectIds
()))
self
.
tic
()
self
.
tic
()
class
TestDocument
(
TestDocumentMixin
):
class
TestDocument
(
TestDocumentMixin
):
"""
"""
Test basic document - related operations
Test basic document - related operations
...
@@ -231,14 +236,18 @@ class TestDocument(TestDocumentMixin):
...
@@ -231,14 +236,18 @@ class TestDocument(TestDocumentMixin):
def
getURLSizeList
(
self
,
uri
,
**
kw
):
def
getURLSizeList
(
self
,
uri
,
**
kw
):
# __ac=RVJQNVR5cGVUZXN0Q2FzZTo%3D is encoded ERP5TypeTestCase with empty password
# __ac=RVJQNVR5cGVUZXN0Q2FzZTo%3D is encoded ERP5TypeTestCase with empty password
url
=
'%s?%s
&__ac=%s'
%
(
uri
,
make_query
(
kw
),
'RVJQNVR5cGVUZXN0Q2FzZTo%3D'
)
url
=
'%s?%s
'
%
(
uri
,
make_query
(
dict
(
kw
,
__ac
=
'RVJQNVR5cGVUZXN0Q2FzZTo%3D'
))
)
format_
=
kw
.
get
(
'format'
,
'jpeg'
)
format_
=
kw
.
get
(
'format'
,
'jpeg'
)
infile
=
urlopen
(
url
)
infile
=
urlopen
(
url
)
try
:
image_data
=
infile
.
read
()
finally
:
infile
.
close
()
# save as file with proper incl. format filename (for some reasons PIL uses this info)
# save as file with proper incl. format filename (for some reasons PIL uses this info)
filename
=
"%s%stest-image-format-resize.%s"
%
(
os
.
getcwd
(),
os
.
sep
,
format_
)
filename
=
"%s%stest-image-format-resize.%s"
%
(
os
.
getcwd
(),
os
.
sep
,
format_
)
with
open
(
filename
,
"wb"
)
as
f
:
with
open
(
filename
,
"wb"
)
as
f
:
f
.
write
(
infile
.
read
())
f
.
write
(
image_data
)
infile
.
close
()
file_size
=
len
(
image_data
)
file_size
=
len
(
image_data
)
try
:
try
:
from
PIL
import
Image
from
PIL
import
Image
...
@@ -279,7 +288,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -279,7 +288,7 @@ class TestDocument(TestDocumentMixin):
# the same document should now have revision 4 (because it should have done mergeRevision)
# the same document should now have revision 4 (because it should have done mergeRevision)
# getRevisionList should return (1, 2, 3, 4)
# getRevisionList should return (1, 2, 3, 4)
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
tic
()
self
.
tic
()
document_url
=
document
.
getRelativeUrl
()
document_url
=
document
.
getRelativeUrl
()
...
@@ -491,38 +500,38 @@ class TestDocument(TestDocumentMixin):
...
@@ -491,38 +500,38 @@ class TestDocument(TestDocumentMixin):
# create docs to be referenced:
# create docs to be referenced:
# (1) TEST, 002, en
# (1) TEST, 002, en
filename
=
'TEST-en-002.odt'
filename
=
'TEST-en-002.odt'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document1
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document1
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# (2) TEST, 002, fr
# (2) TEST, 002, fr
as_name
=
'TEST-fr-002.odt'
as_name
=
'TEST-fr-002.odt'
file_
=
makeFileUpload
(
filename
,
as_name
)
file_
=
self
.
makeFileUpload
(
filename
,
as_name
)
document2
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document2
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# (3) TEST, 003, en
# (3) TEST, 003, en
as_name
=
'TEST-en-003.odt'
as_name
=
'TEST-en-003.odt'
file_
=
makeFileUpload
(
filename
,
as_name
)
file_
=
self
.
makeFileUpload
(
filename
,
as_name
)
document3
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document3
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# create docs to contain references in text_content:
# create docs to contain references in text_content:
# REF, 002, en; "I use reference to look up TEST"
# REF, 002, en; "I use reference to look up TEST"
filename
=
'REF-en-002.odt'
filename
=
'REF-en-002.odt'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document5
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document5
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# REFLANG, 001, en: "I use reference and language to look up TEST-fr"
# REFLANG, 001, en: "I use reference and language to look up TEST-fr"
filename
=
'REFLANG-en-001.odt'
filename
=
'REFLANG-en-001.odt'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document6
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document6
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# REFVER, 001, en: "I use reference and version to look up TEST-002"
# REFVER, 001, en: "I use reference and version to look up TEST-002"
filename
=
'REFVER-en-001.odt'
filename
=
'REFVER-en-001.odt'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document7
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document7
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# REFVERLANG, 001, en: "I use reference, version and language to look up TEST-002-en"
# REFVERLANG, 001, en: "I use reference, version and language to look up TEST-002-en"
filename
=
'REFVERLANG-en-001.odt'
filename
=
'REFVERLANG-en-001.odt'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document8
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document8
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
tic
()
self
.
tic
()
...
@@ -578,7 +587,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -578,7 +587,7 @@ class TestDocument(TestDocumentMixin):
def
test_catalog_search_by_size
(
self
):
def
test_catalog_search_by_size
(
self
):
doc
=
self
.
portal
.
document_module
.
newContent
(
doc
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Spreadsheet'
,
portal_type
=
'Spreadsheet'
,
file
=
makeFileUpload
(
'import_data_list.ods'
))
file
=
self
.
makeFileUpload
(
'import_data_list.ods'
))
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
self
.
assertEqual
(
[
x
.
getObject
()
for
x
in
self
.
portal
.
portal_catalog
(
size
=
doc
.
getSize
())],
[
doc
])
[
x
.
getObject
()
for
x
in
self
.
portal
.
portal_catalog
(
size
=
doc
.
getSize
())],
[
doc
])
...
@@ -586,8 +595,8 @@ class TestDocument(TestDocumentMixin):
...
@@ -586,8 +595,8 @@ class TestDocument(TestDocumentMixin):
def
testOOoDocument_get_size
(
self
):
def
testOOoDocument_get_size
(
self
):
# test get_size on OOoDocument
# test get_size on OOoDocument
doc
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Spreadsheet'
)
doc
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Spreadsheet'
)
doc
.
edit
(
file
=
makeFileUpload
(
'import_data_list.ods'
))
doc
.
edit
(
file
=
self
.
makeFileUpload
(
'import_data_list.ods'
))
self
.
assertEqual
(
len
(
makeFileUpload
(
'import_data_list.ods'
).
read
()),
self
.
assertEqual
(
len
(
self
.
makeFileUpload
(
'import_data_list.ods'
).
read
()),
doc
.
get_size
())
doc
.
get_size
())
def
testTempOOoDocument_get_size
(
self
):
def
testTempOOoDocument_get_size
(
self
):
...
@@ -600,14 +609,14 @@ class TestDocument(TestDocumentMixin):
...
@@ -600,14 +609,14 @@ class TestDocument(TestDocumentMixin):
# test hasData on OOoDocument
# test hasData on OOoDocument
doc
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Spreadsheet'
)
doc
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Spreadsheet'
)
self
.
assertFalse
(
doc
.
hasData
())
self
.
assertFalse
(
doc
.
hasData
())
doc
.
edit
(
file
=
makeFileUpload
(
'import_data_list.ods'
))
doc
.
edit
(
file
=
self
.
makeFileUpload
(
'import_data_list.ods'
))
self
.
assertTrue
(
doc
.
hasData
())
self
.
assertTrue
(
doc
.
hasData
())
def
testTempOOoDocument_hasData
(
self
):
def
testTempOOoDocument_hasData
(
self
):
# test hasData on TempOOoDocument
# test hasData on TempOOoDocument
doc
=
self
.
portal
.
newContent
(
temp_object
=
True
,
portal_type
=
'OOo Document'
,
id
=
'tmp'
)
doc
=
self
.
portal
.
newContent
(
temp_object
=
True
,
portal_type
=
'OOo Document'
,
id
=
'tmp'
)
self
.
assertFalse
(
doc
.
hasData
())
self
.
assertFalse
(
doc
.
hasData
())
doc
.
edit
(
file
=
makeFileUpload
(
'import_data_list.ods'
))
doc
.
edit
(
file
=
self
.
makeFileUpload
(
'import_data_list.ods'
))
self
.
assertTrue
(
doc
.
hasData
())
self
.
assertTrue
(
doc
.
hasData
())
def
test_Owner_Base_download
(
self
):
def
test_Owner_Base_download
(
self
):
...
@@ -617,7 +626,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -617,7 +626,7 @@ class TestDocument(TestDocumentMixin):
doc
=
self
.
portal
.
document_module
.
newContent
(
doc
=
self
.
portal
.
document_module
.
newContent
(
filename
=
'test.ods'
,
filename
=
'test.ods'
,
portal_type
=
'Spreadsheet'
)
portal_type
=
'Spreadsheet'
)
doc
.
edit
(
file
=
makeFileUpload
(
'TEST-en-002.doc'
))
doc
.
edit
(
file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
))
self
.
tic
()
self
.
tic
()
uf
=
self
.
portal
.
acl_users
uf
=
self
.
portal
.
acl_users
...
@@ -627,7 +636,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -627,7 +636,7 @@ class TestDocument(TestDocumentMixin):
response
=
self
.
publish
(
'%s/Base_download'
%
doc
.
getPath
(),
response
=
self
.
publish
(
'%s/Base_download'
%
doc
.
getPath
(),
basic
=
'member_user1:secret'
)
basic
=
'member_user1:secret'
)
self
.
assertEqual
(
makeFileUpload
(
'TEST-en-002.doc'
).
read
(),
self
.
assertEqual
(
self
.
makeFileUpload
(
'TEST-en-002.doc'
).
read
(),
response
.
getBody
())
response
.
getBody
())
self
.
assertEqual
(
'application/msword'
,
self
.
assertEqual
(
'application/msword'
,
response
.
headers
[
'content-type'
])
response
.
headers
[
'content-type'
])
...
@@ -656,7 +665,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -656,7 +665,7 @@ class TestDocument(TestDocumentMixin):
doc
=
self
.
portal
.
document_module
.
newContent
(
doc
=
self
.
portal
.
document_module
.
newContent
(
filename
=
'test.ods'
,
filename
=
'test.ods'
,
portal_type
=
'Spreadsheet'
)
portal_type
=
'Spreadsheet'
)
doc
.
edit
(
file
=
makeFileUpload
(
'import.file.with.dot.in.filename.ods'
))
doc
.
edit
(
file
=
self
.
makeFileUpload
(
'import.file.with.dot.in.filename.ods'
))
doc
.
publish
()
doc
.
publish
()
self
.
tic
()
self
.
tic
()
...
@@ -671,12 +680,8 @@ class TestDocument(TestDocumentMixin):
...
@@ -671,12 +680,8 @@ class TestDocument(TestDocumentMixin):
self
.
assertEqual
(
'attachment; filename="import.file.with.dot.in.filename.pdf"'
,
self
.
assertEqual
(
'attachment; filename="import.file.with.dot.in.filename.pdf"'
,
response
.
getHeader
(
'content-disposition'
))
response
.
getHeader
(
'content-disposition'
))
response_body
=
response
.
getBody
()
response_body
=
response
.
getBody
()
conversion
=
str
(
doc
.
convert
(
'pdf'
)[
1
])
conversion
=
doc
.
convert
(
'pdf'
)[
1
]
diff
=
'
\
n
'
+
'
\
n
'
.
join
(
difflib
.
unified_diff
(
response_body
.
splitlines
(),
self
.
assertEqual
(
response_body
,
conversion
)
conversion
.
splitlines
(),
fromfile
=
'first_call.pdf'
,
tofile
=
'second_call.pdf'
))
self
.
assertEqual
(
response_body
,
conversion
,
diff
)
# test Print icon works on OOoDocument
# test Print icon works on OOoDocument
response
=
self
.
publish
(
'%s/OOoDocument_print'
%
doc
.
getPath
())
response
=
self
.
publish
(
'%s/OOoDocument_print'
%
doc
.
getPath
())
...
@@ -734,13 +739,13 @@ class TestDocument(TestDocumentMixin):
...
@@ -734,13 +739,13 @@ class TestDocument(TestDocumentMixin):
def
test_csv
(
self
):
def
test_csv
(
self
):
doc
=
self
.
portal
.
document_module
.
newContent
(
doc
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Spreadsheet'
,
portal_type
=
'Spreadsheet'
,
file
=
makeFileUpload
(
'simple.csv'
),
file
=
self
.
makeFileUpload
(
'simple.csv'
),
)
)
self
.
assertEqual
(
doc
.
getContentType
(),
'text/csv'
)
self
.
assertEqual
(
doc
.
getContentType
(),
'text/csv'
)
doc
.
publish
()
doc
.
publish
()
self
.
tic
()
self
.
tic
()
response
=
self
.
publish
(
'%s?format='
%
doc
.
getPath
())
response
=
self
.
publish
(
'%s?format='
%
doc
.
getPath
())
self
.
assertEqual
(
response
.
getBody
(),
makeFileUpload
(
'simple.csv'
).
read
())
self
.
assertEqual
(
response
.
getBody
(),
self
.
makeFileUpload
(
'simple.csv'
).
read
())
self
.
assertEqual
(
response
.
getHeader
(
'Content-Type'
),
'text/csv; charset=utf-8'
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Type'
),
'text/csv; charset=utf-8'
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Disposition'
),
'attachment; filename="simple.csv"'
)
self
.
assertEqual
(
response
.
getHeader
(
'Content-Disposition'
),
'attachment; filename="simple.csv"'
)
...
@@ -762,7 +767,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -762,7 +767,7 @@ class TestDocument(TestDocumentMixin):
is not draft
is not draft
"""
"""
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
assertEqual
(
'converting'
,
document
.
getExternalProcessingState
())
self
.
assertEqual
(
'converting'
,
document
.
getExternalProcessingState
())
...
@@ -827,7 +832,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -827,7 +832,7 @@ class TestDocument(TestDocumentMixin):
document.
document.
"""
"""
filename
=
'EmbeddedImage-en-002.odt'
filename
=
'EmbeddedImage-en-002.odt'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
tic
()
self
.
tic
()
...
@@ -1313,7 +1318,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1313,7 +1318,7 @@ class TestDocument(TestDocumentMixin):
re_html_nbsp
=
re
.
compile
(
'&(nbsp|#160);'
)
re_html_nbsp
=
re
.
compile
(
'&(nbsp|#160);'
)
def
test_PDFTextContent
(
self
):
def
test_PDFTextContent
(
self
):
upload_file
=
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
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
self
.
assertEqual
(
'I use reference to look up TEST
\
n
'
,
self
.
assertEqual
(
'I use reference to look up TEST
\
n
'
,
...
@@ -1324,7 +1329,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1324,7 +1329,7 @@ class TestDocument(TestDocumentMixin):
document
.
SearchableText
())
document
.
SearchableText
())
def
test_PDFToPng
(
self
):
def
test_PDFToPng
(
self
):
upload_file
=
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
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
...
@@ -1336,7 +1341,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1336,7 +1341,7 @@ class TestDocument(TestDocumentMixin):
self
.
assertEqual
(
image_data
[
1
:
4
],
b'PNG'
)
self
.
assertEqual
(
image_data
[
1
:
4
],
b'PNG'
)
def
test_PDFToJpg
(
self
):
def
test_PDFToJpg
(
self
):
upload_file
=
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
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
...
@@ -1347,7 +1352,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1347,7 +1352,7 @@ class TestDocument(TestDocumentMixin):
self
.
assertEqual
(
image_data
[
6
:
10
],
b'JFIF'
)
self
.
assertEqual
(
image_data
[
6
:
10
],
b'JFIF'
)
def
test_PDFToGif
(
self
):
def
test_PDFToGif
(
self
):
upload_file
=
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
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
...
@@ -1358,7 +1363,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1358,7 +1363,7 @@ class TestDocument(TestDocumentMixin):
self
.
assertEqual
(
image_data
[
0
:
4
],
b'GIF8'
)
self
.
assertEqual
(
image_data
[
0
:
4
],
b'GIF8'
)
def
test_PDFToTiff
(
self
):
def
test_PDFToTiff
(
self
):
upload_file
=
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
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
...
@@ -1370,7 +1375,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1370,7 +1375,7 @@ class TestDocument(TestDocumentMixin):
def
test_PDF_content_information
(
self
):
def
test_PDF_content_information
(
self
):
upload_file
=
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
)
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
content_information
=
document
.
getContentInformation
()
content_information
=
document
.
getContentInformation
()
...
@@ -1382,7 +1387,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1382,7 +1387,7 @@ class TestDocument(TestDocumentMixin):
def
test_PDF_content_information_extra_metadata
(
self
):
def
test_PDF_content_information_extra_metadata
(
self
):
# Extra metadata, such as those stored by pdftk update_info are also
# Extra metadata, such as those stored by pdftk update_info are also
# available in document.getContentInformation()
# available in document.getContentInformation()
upload_file
=
makeFileUpload
(
'metadata.pdf'
,
as_name
=
'REF-en-001.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'metadata.pdf'
,
as_name
=
'REF-en-001.pdf'
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
self
.
assertEqual
(
'PDF'
,
document
.
getPortalType
())
...
@@ -1393,7 +1398,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1393,7 +1398,7 @@ class TestDocument(TestDocumentMixin):
# contribute file which will be merged to current document in synchronous mode
# contribute file which will be merged to current document in synchronous mode
# and check content_type recalculated
# and check content_type recalculated
upload_file
=
makeFileUpload
(
'Forty-Two.Pages-en-001.pdf'
,
as_name
=
'REF-en-001.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'Forty-Two.Pages-en-001.pdf'
,
as_name
=
'REF-en-001.pdf'
)
contributed_document
=
self
.
portal
.
Base_contribute
(
file
=
upload_file
,
\
contributed_document
=
self
.
portal
.
Base_contribute
(
file
=
upload_file
,
\
synchronous_metadata_discovery
=
True
)
synchronous_metadata_discovery
=
True
)
self
.
tic
()
self
.
tic
()
...
@@ -1407,7 +1412,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1407,7 +1412,7 @@ class TestDocument(TestDocumentMixin):
document
.
getContentInformation
()[
'Pages'
])
document
.
getContentInformation
()[
'Pages'
])
# upload with another file and check content_type recalculated
# upload with another file and check content_type recalculated
upload_file
=
makeFileUpload
(
'REF-en-001.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'REF-en-001.pdf'
)
document
.
setFile
(
upload_file
)
document
.
setFile
(
upload_file
)
self
.
tic
()
self
.
tic
()
content_information
=
document
.
getContentInformation
()
content_information
=
document
.
getContentInformation
()
...
@@ -1425,7 +1430,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1425,7 +1430,7 @@ class TestDocument(TestDocumentMixin):
# IndirectObject instance which is not picklable
# IndirectObject instance which is not picklable
document
=
self
.
portal
.
document_module
.
newContent
(
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
portal_type
=
'PDF'
,
file
=
makeFileUpload
(
'apple_metadata.pdf'
))
file
=
self
.
makeFileUpload
(
'apple_metadata.pdf'
))
# content_information is picklable
# content_information is picklable
content_information
=
document
.
getContentInformation
()
content_information
=
document
.
getContentInformation
()
from
pickle
import
dumps
from
pickle
import
dumps
...
@@ -1438,7 +1443,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1438,7 +1443,7 @@ class TestDocument(TestDocumentMixin):
""" Test that pypdf2 handle wrong formatted PDF """
""" Test that pypdf2 handle wrong formatted PDF """
pdf
=
self
.
portal
.
document_module
.
newContent
(
pdf
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
portal_type
=
'PDF'
,
file
=
makeFileUpload
(
'FEUILLE BLANCHE.pdf'
),
file
=
self
.
makeFileUpload
(
'FEUILLE BLANCHE.pdf'
),
title
=
'Bad PDF'
)
title
=
'Bad PDF'
)
self
.
tic
()
self
.
tic
()
pdf
.
share
()
pdf
.
share
()
...
@@ -1448,7 +1453,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1448,7 +1453,7 @@ class TestDocument(TestDocumentMixin):
self
.
assertNotEqual
(
result
,
None
)
self
.
assertNotEqual
(
result
,
None
)
def
test_PDF_content_content_type
(
self
):
def
test_PDF_content_content_type
(
self
):
upload_file
=
makeFileUpload
(
'REF-en-001.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'REF-en-001.pdf'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
)
# Here we use edit instead of setFile,
# Here we use edit instead of setFile,
# because only edit method set filename as filename.
# because only edit method set filename as filename.
...
@@ -1457,17 +1462,17 @@ class TestDocument(TestDocumentMixin):
...
@@ -1457,17 +1462,17 @@ class TestDocument(TestDocumentMixin):
def
test_PDF_watermark
(
self
):
def
test_PDF_watermark
(
self
):
original_document
=
self
.
portal
.
portal_contributions
.
newContent
(
original_document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'REF-en-001.pdf'
))
file
=
self
.
makeFileUpload
(
'REF-en-001.pdf'
))
# This watermark.pdf document is a pdf with a transparent background. Such
# This watermark.pdf document is a pdf with a transparent background. Such
# document can be created using GIMP
# document can be created using GIMP
watermark_document
=
self
.
portal
.
portal_contributions
.
newContent
(
watermark_document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'watermark.pdf'
))
file
=
self
.
makeFileUpload
(
'watermark.pdf'
))
watermarked_data
=
original_document
.
getWatermarkedData
(
watermarked_data
=
original_document
.
getWatermarkedData
(
watermark_data
=
watermark_document
.
getData
(),
watermark_data
=
watermark_document
.
getData
(),
repeat_watermark
=
False
)
repeat_watermark
=
False
)
# this looks like a pdf
# 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
# and ERP5 can make a PDF Document out of it
watermarked_document
=
self
.
portal
.
document_module
.
newContent
(
watermarked_document
=
self
.
portal
.
document_module
.
newContent
(
...
@@ -1480,14 +1485,14 @@ class TestDocument(TestDocumentMixin):
...
@@ -1480,14 +1485,14 @@ class TestDocument(TestDocumentMixin):
def
test_PDF_watermark_repeat
(
self
):
def
test_PDF_watermark_repeat
(
self
):
# watermark a pdf, repeating the watermark
# watermark a pdf, repeating the watermark
original_document
=
self
.
portal
.
portal_contributions
.
newContent
(
original_document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'Forty-Two.Pages-en-001.pdf'
))
file
=
self
.
makeFileUpload
(
'Forty-Two.Pages-en-001.pdf'
))
watermark_document
=
self
.
portal
.
portal_contributions
.
newContent
(
watermark_document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'watermark.pdf'
))
file
=
self
.
makeFileUpload
(
'watermark.pdf'
))
watermarked_data
=
original_document
.
getWatermarkedData
(
watermarked_data
=
original_document
.
getWatermarkedData
(
watermark_data
=
watermark_document
.
getData
(),
watermark_data
=
watermark_document
.
getData
(),
repeat_watermark
=
True
)
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
(
watermarked_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
portal_type
=
'PDF'
,
data
=
watermarked_data
)
data
=
watermarked_data
)
...
@@ -1498,15 +1503,15 @@ class TestDocument(TestDocumentMixin):
...
@@ -1498,15 +1503,15 @@ class TestDocument(TestDocumentMixin):
def
test_PDF_watermark_start_page
(
self
):
def
test_PDF_watermark_start_page
(
self
):
# watermark a pdf, starting on the second page
# watermark a pdf, starting on the second page
original_document
=
self
.
portal
.
portal_contributions
.
newContent
(
original_document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'Forty-Two.Pages-en-001.pdf'
))
file
=
self
.
makeFileUpload
(
'Forty-Two.Pages-en-001.pdf'
))
watermark_document
=
self
.
portal
.
portal_contributions
.
newContent
(
watermark_document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'watermark.pdf'
))
file
=
self
.
makeFileUpload
(
'watermark.pdf'
))
watermarked_data
=
original_document
.
getWatermarkedData
(
watermarked_data
=
original_document
.
getWatermarkedData
(
watermark_data
=
watermark_document
.
getData
(),
watermark_data
=
watermark_document
.
getData
(),
repeat_watermark
=
False
,
repeat_watermark
=
False
,
watermark_start_page
=
1
)
# This is 0 based.
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
(
watermarked_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
portal_type
=
'PDF'
,
data
=
watermarked_data
)
data
=
watermarked_data
)
...
@@ -1515,7 +1520,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1515,7 +1520,7 @@ class TestDocument(TestDocumentMixin):
watermarked_document
.
getData
())
watermarked_document
.
getData
())
def
test_checkVisibleTextInPresentationToImageConversion
(
self
):
def
test_checkVisibleTextInPresentationToImageConversion
(
self
):
odp
=
makeFileUpload
(
"TEST-en-003.odp"
)
odp
=
self
.
makeFileUpload
(
"TEST-en-003.odp"
)
presentation
=
self
.
portal
.
document_module
.
newContent
(
presentation
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
"Presentation"
,
portal_type
=
"Presentation"
,
data
=
odp
,
data
=
odp
,
...
@@ -1535,7 +1540,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1535,7 +1540,7 @@ class TestDocument(TestDocumentMixin):
self
.
assertIn
(
"ERP5 DMS page 1"
,
txt
)
self
.
assertIn
(
"ERP5 DMS page 1"
,
txt
)
def
test_Document_getStandardFilename
(
self
):
def
test_Document_getStandardFilename
(
self
):
upload_file
=
makeFileUpload
(
'metadata.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'metadata.pdf'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
)
document
.
edit
(
file
=
upload_file
)
document
.
edit
(
file
=
upload_file
)
self
.
assertEqual
(
document
.
getStandardFilename
(),
'metadata.pdf'
)
self
.
assertEqual
(
document
.
getStandardFilename
(),
'metadata.pdf'
)
...
@@ -1547,7 +1552,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1547,7 +1552,7 @@ class TestDocument(TestDocumentMixin):
self
.
assertEqual
(
document
.
getStandardFilename
(
format
=
'png'
),
self
.
assertEqual
(
document
.
getStandardFilename
(
format
=
'png'
),
'metadata-001-en.png'
)
'metadata-001-en.png'
)
# check when format contains multiple '.'
# check when format contains multiple '.'
upload_file
=
makeFileUpload
(
'TEST-en-003.odp'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-003.odp'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
document
.
edit
(
file
=
upload_file
)
document
.
edit
(
file
=
upload_file
)
self
.
assertEqual
(
document
.
getStandardFilename
(),
'TEST-en-003.odp'
)
self
.
assertEqual
(
document
.
getStandardFilename
(),
'TEST-en-003.odp'
)
...
@@ -1555,18 +1560,18 @@ class TestDocument(TestDocumentMixin):
...
@@ -1555,18 +1560,18 @@ class TestDocument(TestDocumentMixin):
def
test_CMYKImageTextContent
(
self
):
def
test_CMYKImageTextContent
(
self
):
upload_file
=
makeFileUpload
(
'cmyk_sample.jpg'
)
upload_file
=
self
.
makeFileUpload
(
'cmyk_sample.jpg'
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
self
.
assertEqual
(
'Image'
,
document
.
getPortalType
())
self
.
assertEqual
(
'Image'
,
document
.
getPortalType
())
self
.
assertEqual
(
'ERP5 is a free software.'
,
document
.
asText
())
self
.
assertEqual
(
'ERP5 is a free software.'
,
document
.
asText
())
def
test_MonochromeImageResize
(
self
):
def
test_MonochromeImageResize
(
self
):
upload_file
=
makeFileUpload
(
'monochrome_sample.tiff'
)
upload_file
=
self
.
makeFileUpload
(
'monochrome_sample.tiff'
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
self
.
assertEqual
(
'Image'
,
document
.
getPortalType
())
self
.
assertEqual
(
'Image'
,
document
.
getPortalType
())
resized_image
=
document
.
convert
(
format
=
'png'
,
display
=
'small'
)[
1
]
resized_image
=
document
.
convert
(
format
=
'png'
,
display
=
'small'
)[
1
]
identify_output
=
Popen
([
'identify'
,
'-verbose'
,
'-'
],
stdin
=
PIPE
,
stdout
=
PIPE
).
communicate
(
resized_image
)[
0
]
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
())
self
.
assertEqual
(
'ERP5 is a free software.'
,
document
.
asText
())
def
test_Base_showFoundText
(
self
):
def
test_Base_showFoundText
(
self
):
...
@@ -1574,7 +1579,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1574,7 +1579,7 @@ class TestDocument(TestDocumentMixin):
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Drawing'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Drawing'
)
self
.
assertEqual
(
'empty'
,
document
.
getExternalProcessingState
())
self
.
assertEqual
(
'empty'
,
document
.
getExternalProcessingState
())
upload_file
=
makeFileUpload
(
'TEST-en-002.odt'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.odt'
)
document
.
edit
(
file
=
upload_file
)
document
.
edit
(
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
'converted'
,
document
.
getExternalProcessingState
())
self
.
assertEqual
(
'converted'
,
document
.
getExternalProcessingState
())
...
@@ -1589,7 +1594,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1589,7 +1594,7 @@ class TestDocument(TestDocumentMixin):
document
.
Base_showFoundText
())
document
.
Base_showFoundText
())
# upload again good content
# upload again good content
upload_file
=
makeFileUpload
(
'TEST-en-002.odt'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.odt'
)
document
.
edit
(
file
=
upload_file
)
document
.
edit
(
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
'converted'
,
document
.
getExternalProcessingState
())
self
.
assertEqual
(
'converted'
,
document
.
getExternalProcessingState
())
...
@@ -1600,18 +1605,18 @@ class TestDocument(TestDocumentMixin):
...
@@ -1600,18 +1605,18 @@ class TestDocument(TestDocumentMixin):
Check that encoding remains.
Check that encoding remains.
"""
"""
web_page_portal_type
=
'Web Page'
web_page_portal_type
=
'Web Page'
string_to_test
=
'éààéôù'
string_to_test
=
u
'éààéôù'
web_page
=
self
.
portal
.
getDefaultModule
(
web_page_portal_type
)
\
web_page
=
self
.
portal
.
getDefaultModule
(
web_page_portal_type
)
\
.
newContent
(
portal_type
=
web_page_portal_type
)
.
newContent
(
portal_type
=
web_page_portal_type
)
html_content
=
'<p>%s</p>'
%
string_to_test
html_content
=
u
'<p>%s</p>'
%
string_to_test
web_page
.
edit
(
text_content
=
html_content
)
web_page
.
edit
(
text_content
=
html_content
)
_
,
pdf_data
=
web_page
.
convert
(
'pdf'
)
_
,
pdf_data
=
web_page
.
convert
(
'pdf'
)
text_content
=
self
.
portal
.
portal_transforms
.
\
text_content
=
self
.
portal
.
portal_transforms
.
\
convertToData
(
'text/plain'
,
convertToData
(
'text/plain'
,
str
(
pdf_data
),
bytes
(
pdf_data
),
object
=
web_page
,
context
=
web_page
,
object
=
web_page
,
context
=
web_page
,
filename
=
'test.pdf'
)
filename
=
'test.pdf'
)
self
.
assertIn
(
string_to_test
,
text_content
)
self
.
assertIn
(
string_to_test
,
text_content
.
decode
(
'utf-8'
)
)
def
test_HTML_to_ODT_conversion_keep_related_image_list
(
self
):
def
test_HTML_to_ODT_conversion_keep_related_image_list
(
self
):
"""This test create a Web Page and an Image.
"""This test create a Web Page and an Image.
...
@@ -1633,7 +1638,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1633,7 +1638,7 @@ class TestDocument(TestDocumentMixin):
.
newContent
(
portal_type
=
image_portal_type
)
.
newContent
(
portal_type
=
image_portal_type
)
# edit content and publish it
# edit content and publish it
upload_file
=
makeFileUpload
(
'cmyk_sample.jpg'
)
upload_file
=
self
.
makeFileUpload
(
'cmyk_sample.jpg'
)
image
.
edit
(
reference
=
image_reference
,
image
.
edit
(
reference
=
image_reference
,
version
=
'001'
,
version
=
'001'
,
language
=
'en'
,
language
=
'en'
,
...
@@ -1669,7 +1674,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1669,7 +1674,7 @@ class TestDocument(TestDocumentMixin):
# Let's continue with Presentation Document as embbeded image
# Let's continue with Presentation Document as embbeded image
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
upload_file
=
makeFileUpload
(
'TEST-en-003.odp'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-003.odp'
)
image_reference
=
'IMAGE-odp'
image_reference
=
'IMAGE-odp'
document
.
edit
(
file
=
upload_file
,
reference
=
image_reference
)
document
.
edit
(
file
=
upload_file
,
reference
=
image_reference
)
document
.
publish
()
document
.
publish
()
...
@@ -1740,7 +1745,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1740,7 +1745,7 @@ class TestDocument(TestDocumentMixin):
module
=
self
.
portal
.
getDefaultModule
(
web_page_portal_type
)
module
=
self
.
portal
.
getDefaultModule
(
web_page_portal_type
)
web_page
=
module
.
newContent
(
portal_type
=
web_page_portal_type
)
web_page
=
module
.
newContent
(
portal_type
=
web_page_portal_type
)
html_content
=
"""<html>
html_content
=
u
"""<html>
<head>
<head>
<meta http-equiv="refresh" content="5;url=http://example.com/"/>
<meta http-equiv="refresh" content="5;url=http://example.com/"/>
<meta http-equiv="Set-Cookie" content=""/>
<meta http-equiv="Set-Cookie" content=""/>
...
@@ -1766,9 +1771,7 @@ class TestDocument(TestDocumentMixin):
...
@@ -1766,9 +1771,7 @@ class TestDocument(TestDocumentMixin):
</body>
</body>
</html>
</html>
"""
"""
if
six
.
PY2
:
html_content
=
html_content
.
encode
(
'iso-8859-1'
)
html_content
=
html_content
.
decode
(
'utf-8'
).
encode
(
'iso-8859-1'
)
# content encoded into another codec
# content encoded into another codec
# than utf-8 comes from necessarily an external file
# than utf-8 comes from necessarily an external file
# (Ingestion, or FileField), not from user interface
# (Ingestion, or FileField), not from user interface
...
@@ -1777,12 +1780,8 @@ class TestDocument(TestDocumentMixin):
...
@@ -1777,12 +1780,8 @@ class TestDocument(TestDocumentMixin):
# as it is done in reality
# as it is done in reality
# Mimic the behaviour of a FileUpload from WebPage_view
# Mimic the behaviour of a FileUpload from WebPage_view
file_like
=
StringIO
()
file_like
=
io
.
BytesIO
(
html_content
)
file_like
.
write
(
html_content
)
file_like
.
filename
=
'something.htm'
setattr
(
file_like
,
'filename'
,
'something.htm'
)
if
six
.
PY3
:
from
io
import
BytesIO
file_like
=
BytesIO
(
file_like
.
getvalue
().
encode
())
web_page
.
edit
(
file
=
file_like
)
web_page
.
edit
(
file
=
file_like
)
# run conversion to base format
# run conversion to base format
self
.
tic
()
self
.
tic
()
...
@@ -1889,7 +1888,7 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
...
@@ -1889,7 +1888,7 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
self
.
assertNotIn
(
'#FFAA44'
,
safe_html
)
self
.
assertNotIn
(
'#FFAA44'
,
safe_html
)
filename
=
'broken_html.html'
filename
=
'broken_html.html'
file_object
=
makeFileUpload
(
filename
)
file_object
=
self
.
makeFileUpload
(
filename
)
web_page
.
edit
(
file
=
file_object
)
web_page
.
edit
(
file
=
file_object
)
assert
web_page
.
convert
(
'html'
)[
1
]
assert
web_page
.
convert
(
'html'
)[
1
]
...
@@ -1949,7 +1948,7 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
...
@@ -1949,7 +1948,7 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
document_module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
document_module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
document
=
document_module
.
newContent
(
portal_type
=
portal_type
)
document
=
document_module
.
newContent
(
portal_type
=
portal_type
)
upload_file
=
makeFileUpload
(
'Forty-Two.Pages-en-001.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'Forty-Two.Pages-en-001.pdf'
)
document
.
edit
(
file
=
upload_file
)
document
.
edit
(
file
=
upload_file
)
pages_number
=
int
(
document
.
getContentInformation
()[
'Pages'
])
pages_number
=
int
(
document
.
getContentInformation
()[
'Pages'
])
self
.
tic
()
self
.
tic
()
...
@@ -2053,16 +2052,24 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
...
@@ -2053,16 +2052,24 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
"""
"""
web_page_portal_type
=
'Web Page'
web_page_portal_type
=
'Web Page'
module
=
self
.
portal
.
getDefaultModule
(
web_page_portal_type
)
module
=
self
.
portal
.
getDefaultModule
(
web_page_portal_type
)
upload_file
=
makeFileUpload
(
'TEST-text-iso8859-1.txt'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-text-iso8859-1.txt'
)
web_page
=
module
.
newContent
(
portal_type
=
web_page_portal_type
,
web_page
=
module
.
newContent
(
portal_type
=
web_page_portal_type
,
file
=
upload_file
)
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
web_page
.
getContentType
(),
'text/plain'
)
text_content
=
web_page
.
getTextContent
()
text_content
=
web_page
.
getTextContent
()
my_utf_eight_token
=
'ùééàçèîà'
self
.
assertIn
(
'éèàùôâïî'
,
text_content
)
text_content
=
text_content
.
replace
(
'
\
n
'
,
'
\
n
%s
\
n
'
%
my_utf_eight_token
)
self
.
assertIn
(
'éèàùôâïî'
,
web_page
.
asStrippedHTML
())
self
.
assertIn
(
'éèàùôâïî'
,
web_page
.
asEntireHTML
())
added_utf_eight_token
=
'ùééàçèîà'
text_content
=
text_content
.
replace
(
'
\
n
'
,
'
\
n
%s
\
n
'
%
added_utf_eight_token
)
web_page
.
edit
(
text_content
=
text_content
)
web_page
.
edit
(
text_content
=
text_content
)
self
.
assertIn
(
my_utf_eight_token
,
web_page
.
asStrippedHTML
())
self
.
assertIn
(
'éèàùôâïî'
,
web_page
.
asStrippedHTML
())
self
.
assertTrue
(
isinstance
(
web_page
.
asEntireHTML
().
decode
(
'utf-8'
),
unicode
))
self
.
assertIn
(
'éèàùôâïî'
,
web_page
.
asEntireHTML
())
self
.
assertIn
(
added_utf_eight_token
,
web_page
.
asStrippedHTML
())
self
.
assertIn
(
added_utf_eight_token
,
web_page
.
asEntireHTML
())
def
test_PDFDocument_asTextConversion
(
self
):
def
test_PDFDocument_asTextConversion
(
self
):
"""Test a PDF document with embedded images
"""Test a PDF document with embedded images
...
@@ -2070,24 +2077,24 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
...
@@ -2070,24 +2077,24 @@ document.write('<sc'+'ript type="text/javascript" src="http://somosite.bg/utb.ph
"""
"""
document
=
self
.
portal
.
document_module
.
newContent
(
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
portal_type
=
'PDF'
,
file
=
makeFileUpload
(
'TEST.Embedded.Image.pdf'
))
file
=
self
.
makeFileUpload
(
'TEST.Embedded.Image.pdf'
))
self
.
assertEqual
(
document
.
asText
(),
'ERP5 is a free software.'
)
self
.
assertEqual
(
document
.
asText
(),
'ERP5 is a free software.'
)
def
test_broken_pdf_asText
(
self
):
def
test_broken_pdf_asText
(
self
):
class
StringIOWithFilename
(
String
IO
):
class
BytesIOWithFilename
(
io
.
Bytes
IO
):
filename
=
'broken.pdf'
filename
=
'broken.pdf'
document
=
self
.
portal
.
document_module
.
newContent
(
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
portal_type
=
'PDF'
,
file
=
StringIOWithFilename
(
'broken'
))
file
=
BytesIOWithFilename
(
b
'broken'
))
self
.
assertEqual
(
document
.
asText
(),
''
)
self
.
assertEqual
(
document
.
asText
(),
''
)
self
.
tic
()
# no activity failure
self
.
tic
()
# no activity failure
def
test_password_protected_pdf_asText
(
self
):
def
test_password_protected_pdf_asText
(
self
):
pdf_reader
=
PyPDF2
.
PdfFileReader
(
makeFileUpload
(
'TEST.Embedded.Image.pdf'
))
pdf_reader
=
PyPDF2
.
PdfFileReader
(
self
.
makeFileUpload
(
'TEST.Embedded.Image.pdf'
))
pdf_writer
=
PyPDF2
.
PdfFileWriter
()
pdf_writer
=
PyPDF2
.
PdfFileWriter
()
pdf_writer
.
addPage
(
pdf_reader
.
getPage
(
0
))
pdf_writer
.
addPage
(
pdf_reader
.
getPage
(
0
))
pdf_writer
.
encrypt
(
'secret'
)
pdf_writer
.
encrypt
(
'secret'
)
encrypted_pdf_stream
=
String
IO
()
encrypted_pdf_stream
=
io
.
Bytes
IO
()
pdf_writer
.
write
(
encrypted_pdf_stream
)
pdf_writer
.
write
(
encrypted_pdf_stream
)
document
=
self
.
portal
.
document_module
.
newContent
(
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
,
portal_type
=
'PDF'
,
...
@@ -2109,7 +2116,7 @@ return 1
...
@@ -2109,7 +2116,7 @@ return 1
def
_test_document_conversion_to_base_format_no_original_format_access
(
self
,
def
_test_document_conversion_to_base_format_no_original_format_access
(
self
,
portal_type
,
filename
):
portal_type
,
filename
):
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
upload_file
=
makeFileUpload
(
filename
)
upload_file
=
self
.
makeFileUpload
(
filename
)
document
=
module
.
newContent
(
portal_type
=
portal_type
,
document
=
module
.
newContent
(
portal_type
=
portal_type
,
file
=
upload_file
)
file
=
upload_file
)
...
@@ -2161,7 +2168,7 @@ return 1
...
@@ -2161,7 +2168,7 @@ return 1
self
.
commit
()
self
.
commit
()
# Create document with good content
# Create document with good content
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
upload_file
=
makeFileUpload
(
'TEST-en-003.odp'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-003.odp'
)
document
.
edit
(
file
=
upload_file
)
document
.
edit
(
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
'converted'
,
document
.
getExternalProcessingState
())
self
.
assertEqual
(
'converted'
,
document
.
getExternalProcessingState
())
...
@@ -2169,12 +2176,12 @@ return 1
...
@@ -2169,12 +2176,12 @@ return 1
for
credential
in
[
'ERP5TypeTestCase:'
,
'zope_user:'
]:
for
credential
in
[
'ERP5TypeTestCase:'
,
'zope_user:'
]:
response
=
self
.
publish
(
'%s/%s'
%
(
document
.
getPath
(),
object_url
),
response
=
self
.
publish
(
'%s/%s'
%
(
document
.
getPath
(),
object_url
),
basic
=
credential
)
basic
=
credential
)
self
.
assertIn
(
'200 OK'
,
response
.
getOutput
())
self
.
assertIn
(
b
'200 OK'
,
response
.
getOutput
())
# OOod produced HTML navigation, test it
# OOod produced HTML navigation, test it
self
.
assertIn
(
'First page'
,
response
.
getBody
())
self
.
assertIn
(
b
'First page'
,
response
.
getBody
())
self
.
assertIn
(
'Back'
,
response
.
getBody
())
self
.
assertIn
(
b
'Back'
,
response
.
getBody
())
self
.
assertIn
(
'Continue'
,
response
.
getBody
())
self
.
assertIn
(
b
'Continue'
,
response
.
getBody
())
self
.
assertIn
(
'Last page'
,
response
.
getBody
())
self
.
assertIn
(
b
'Last page'
,
response
.
getBody
())
def
test_getTargetFormatItemList
(
self
):
def
test_getTargetFormatItemList
(
self
):
"""
"""
...
@@ -2186,7 +2193,7 @@ return 1
...
@@ -2186,7 +2193,7 @@ return 1
portal_type
=
'PDF'
portal_type
=
'PDF'
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
upload_file
=
makeFileUpload
(
'TEST.Large.Document.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'TEST.Large.Document.pdf'
)
pdf
=
module
.
newContent
(
portal_type
=
portal_type
,
file
=
upload_file
)
pdf
=
module
.
newContent
(
portal_type
=
portal_type
,
file
=
upload_file
)
self
.
assertIn
(
'html'
,
pdf
.
getTargetFormatList
())
self
.
assertIn
(
'html'
,
pdf
.
getTargetFormatList
())
...
@@ -2207,7 +2214,7 @@ return 1
...
@@ -2207,7 +2214,7 @@ return 1
self
.
assertSameSet
([],
presentation
.
getTargetFormatList
())
self
.
assertSameSet
([],
presentation
.
getTargetFormatList
())
# test uploading some data
# test uploading some data
upload_file
=
makeFileUpload
(
'Foo_001.odg'
)
upload_file
=
self
.
makeFileUpload
(
'Foo_001.odg'
)
presentation
.
edit
(
file
=
upload_file
)
presentation
.
edit
(
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
self
.
assertIn
(
'odg'
,
presentation
.
getTargetFormatList
())
self
.
assertIn
(
'odg'
,
presentation
.
getTargetFormatList
())
...
@@ -2235,7 +2242,7 @@ return 1
...
@@ -2235,7 +2242,7 @@ return 1
# images from same instance accessed by reference and wrong conversion arguments (dispay NOT display)
# images from same instance accessed by reference and wrong conversion arguments (dispay NOT display)
# code should be more resilient
# code should be more resilient
upload_file
=
makeFileUpload
(
'cmyk_sample.jpg'
)
upload_file
=
self
.
makeFileUpload
(
'cmyk_sample.jpg'
)
image
=
self
.
portal
.
image_module
.
newContent
(
portal_type
=
'Image'
,
image
=
self
.
portal
.
image_module
.
newContent
(
portal_type
=
'Image'
,
reference
=
'Embedded-XXX'
,
reference
=
'Embedded-XXX'
,
version
=
'001'
,
version
=
'001'
,
...
@@ -2278,15 +2285,15 @@ return 1
...
@@ -2278,15 +2285,15 @@ return 1
"""
"""
# Create OOo document
# Create OOo document
ooo_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
ooo_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
upload_file
=
makeFileUpload
(
'TEST-en-003.odp'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-003.odp'
)
ooo_document
.
edit
(
file
=
upload_file
)
ooo_document
.
edit
(
file
=
upload_file
)
pdf_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
)
pdf_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
)
upload_file
=
makeFileUpload
(
'TEST-en-002.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
)
pdf_document
.
edit
(
file
=
upload_file
)
pdf_document
.
edit
(
file
=
upload_file
)
image_document
=
self
.
portal
.
image_module
.
newContent
(
portal_type
=
'Image'
)
image_document
=
self
.
portal
.
image_module
.
newContent
(
portal_type
=
'Image'
)
upload_file
=
makeFileUpload
(
'TEST-en-002.png'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.png'
)
image_document
.
edit
(
file
=
upload_file
)
image_document
.
edit
(
file
=
upload_file
)
web_page_document
=
self
.
portal
.
web_page_module
.
newContent
(
portal_type
=
"Web Page"
)
web_page_document
=
self
.
portal
.
web_page_module
.
newContent
(
portal_type
=
"Web Page"
)
...
@@ -2370,19 +2377,19 @@ return 1
...
@@ -2370,19 +2377,19 @@ return 1
"""
"""
def
getURL
(
uri
,
**
kw
):
def
getURL
(
uri
,
**
kw
):
# __ac=RVJQNVR5cGVUZXN0Q2FzZTo%3D is encoded ERP5TypeTestCase with empty password
# __ac=RVJQNVR5cGVUZXN0Q2FzZTo%3D is encoded ERP5TypeTestCase with empty password
url
=
'%s?%s
&__ac=%s'
%
(
uri
,
urlencode
(
kw
),
'RVJQNVR5cGVUZXN0Q2FzZTo%3D'
)
url
=
'%s?%s
'
%
(
uri
,
urlencode
(
dict
(
kw
,
__ac
=
'RVJQNVR5cGVUZXN0Q2FzZTo%3D'
))
)
return
urlopen
(
url
)
return
urlopen
(
url
)
ooo_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
ooo_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
upload_file
=
makeFileUpload
(
'TEST-en-003.odp'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-003.odp'
)
ooo_document
.
edit
(
file
=
upload_file
)
ooo_document
.
edit
(
file
=
upload_file
)
pdf_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
)
pdf_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'PDF'
)
upload_file
=
makeFileUpload
(
'TEST-en-002.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
)
pdf_document
.
edit
(
file
=
upload_file
)
pdf_document
.
edit
(
file
=
upload_file
)
image_document
=
self
.
portal
.
image_module
.
newContent
(
portal_type
=
'Image'
)
image_document
=
self
.
portal
.
image_module
.
newContent
(
portal_type
=
'Image'
)
upload_file
=
makeFileUpload
(
'TEST-en-002.png'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.png'
)
image_document
.
edit
(
file
=
upload_file
)
image_document
.
edit
(
file
=
upload_file
)
web_page_document
=
self
.
portal
.
web_page_module
.
newContent
(
portal_type
=
"Web Page"
)
web_page_document
=
self
.
portal
.
web_page_module
.
newContent
(
portal_type
=
"Web Page"
)
...
@@ -2391,25 +2398,25 @@ return 1
...
@@ -2391,25 +2398,25 @@ return 1
web_page_document
.
setTextContentSubstitutionMappingMethodId
(
'WebPage_getStandardSubstitutionMappingDict'
)
web_page_document
.
setTextContentSubstitutionMappingMethodId
(
'WebPage_getStandardSubstitutionMappingDict'
)
self
.
tic
()
self
.
tic
()
response
=
getURL
(
image_document
.
absolute_url
(),
**
{
'format'
:
''
})
response
=
getURL
(
image_document
.
absolute_url
(),
**
{
'format'
:
''
})
self
.
assert
In
(
'Content-Type: image/png
\
r
\
n
'
,
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Type'
),
'image/png'
)
self
.
assert
In
(
'Content-Length: %s
\
r
\
n
'
%
getFileSize
(
'TEST-en-002.png'
),
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Length'
),
str
(
getFileSize
(
'TEST-en-002.png'
))
)
response
=
getURL
(
ooo_document
.
absolute_url
(),
**
{
'format'
:
''
})
response
=
getURL
(
ooo_document
.
absolute_url
(),
**
{
'format'
:
''
})
self
.
assert
In
(
'Content-Type: application/vnd.oasis.opendocument.presentation
\
r
\
n
'
,
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Type'
),
'application/vnd.oasis.opendocument.presentation'
)
self
.
assert
In
(
'Content-Disposition: attachment; filename="TEST-en-003.odp"
\
r
\
n
'
,
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Disposition'
),
'attachment; filename="TEST-en-003.odp"'
)
self
.
assert
In
(
'Content-Length: %s
\
r
\
n
'
%
getFileSize
(
'TEST-en-003.odp'
),
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Length'
),
str
(
getFileSize
(
'TEST-en-003.odp'
))
)
response
=
getURL
(
pdf_document
.
absolute_url
(),
**
{
'format'
:
''
})
response
=
getURL
(
pdf_document
.
absolute_url
(),
**
{
'format'
:
''
})
self
.
assert
In
(
'Content-Type: application/pdf
\
r
\
n
'
,
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Type'
),
'application/pdf'
)
self
.
assert
In
(
'Content-Disposition: attachment; filename="TEST-en-002.pdf"
\
r
\
n
'
,
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Disposition'
),
'attachment; filename="TEST-en-002.pdf"'
)
response
=
getURL
(
pdf_document
.
absolute_url
(),
**
{
'format'
:
'pdf'
})
response
=
getURL
(
pdf_document
.
absolute_url
(),
**
{
'format'
:
'pdf'
})
self
.
assert
In
(
'Content-Type: application/pdf
\
r
\
n
'
,
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Type'
),
'application/pdf'
)
self
.
assert
In
(
'Content-Disposition: attachment; filename="TEST-en-002.pdf"
\
r
\
n
'
,
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Disposition'
),
'attachment; filename="TEST-en-002.pdf"'
)
response
=
getURL
(
web_page_document
.
absolute_url
(),
**
{
'format'
:
''
})
response
=
getURL
(
web_page_document
.
absolute_url
(),
**
{
'format'
:
''
})
self
.
assert
In
(
'Content-Type: text/html; charset=utf-8
\
r
\
n
'
,
response
.
info
().
headers
)
self
.
assert
Equal
(
response
.
info
().
get
(
'Content-Type'
),
'text/html; charset=utf-8'
)
def
test_checkConversionFormatPermission
(
self
):
def
test_checkConversionFormatPermission
(
self
):
"""
"""
...
@@ -2417,7 +2424,7 @@ return 1
...
@@ -2417,7 +2424,7 @@ return 1
"""
"""
portal_type
=
'PDF'
portal_type
=
'PDF'
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
upload_file
=
makeFileUpload
(
'TEST.Large.Document.pdf'
)
upload_file
=
self
.
makeFileUpload
(
'TEST.Large.Document.pdf'
)
pdf
=
module
.
newContent
(
portal_type
=
portal_type
,
file
=
upload_file
)
pdf
=
module
.
newContent
(
portal_type
=
portal_type
,
file
=
upload_file
)
# if PDF size is larger than A4 format system should deny conversion
# if PDF size is larger than A4 format system should deny conversion
...
@@ -2426,7 +2433,7 @@ return 1
...
@@ -2426,7 +2433,7 @@ return 1
# raster -> svg image should deny conversion if image width or height > 128 px
# raster -> svg image should deny conversion if image width or height > 128 px
portal_type
=
'Image'
portal_type
=
'Image'
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
upload_file
=
makeFileUpload
(
'TEST-en-002.jpg'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.jpg'
)
image
=
module
.
newContent
(
portal_type
=
portal_type
,
file
=
upload_file
)
image
=
module
.
newContent
(
portal_type
=
portal_type
,
file
=
upload_file
)
self
.
assertRaises
(
Unauthorized
,
image
.
convert
,
format
=
'svg'
)
self
.
assertRaises
(
Unauthorized
,
image
.
convert
,
format
=
'svg'
)
...
@@ -2436,7 +2443,7 @@ return 1
...
@@ -2436,7 +2443,7 @@ return 1
return a default (i.e. indicating a conversion failures)
return a default (i.e. indicating a conversion failures)
"""
"""
doc
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
doc
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Presentation'
)
upload_file
=
makeFileUpload
(
'TEST-en-003.odp'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-003.odp'
)
doc
.
edit
(
file
=
upload_file
)
doc
.
edit
(
file
=
upload_file
)
doc
.
publish
()
doc
.
publish
()
self
.
tic
()
self
.
tic
()
...
@@ -2564,7 +2571,7 @@ return 1
...
@@ -2564,7 +2571,7 @@ return 1
Test various cases of contributing to an existing document
Test various cases of contributing to an existing document
"""
"""
# contribute a document, then make it not editable and check we can not contribute to it
# contribute a document, then make it not editable and check we can not contribute to it
upload_file
=
makeFileUpload
(
'TEST-en-002.doc'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
self
.
tic
()
self
.
tic
()
...
@@ -2589,12 +2596,12 @@ return 1
...
@@ -2589,12 +2596,12 @@ return 1
"""
"""
# contribute a document, then make it not editable and check we can not contribute to it
# contribute a document, then make it not editable and check we can not contribute to it
kw
=
dict
(
synchronous_metadata_discovery
=
True
)
kw
=
dict
(
synchronous_metadata_discovery
=
True
)
upload_file
=
makeFileUpload
(
'TEST-en-002.doc'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
self
.
tic
()
self
.
tic
()
upload_file
=
makeFileUpload
(
'TEST-en-003.odp'
,
'TEST-en-002.doc'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-003.odp'
,
'TEST-en-002.doc'
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
self
.
tic
()
self
.
tic
()
...
@@ -2628,7 +2635,7 @@ return 1
...
@@ -2628,7 +2635,7 @@ return 1
def
test_base_convertable_uses_pdata_for_base_data
(
self
):
def
test_base_convertable_uses_pdata_for_base_data
(
self
):
document
=
self
.
portal
.
document_module
.
newContent
(
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Spreadsheet'
,
portal_type
=
'Spreadsheet'
,
file
=
makeFileUpload
(
'import_big_spreadsheet.ods'
))
file
=
self
.
makeFileUpload
(
'import_big_spreadsheet.ods'
))
self
.
tic
()
self
.
tic
()
# for large documents base_data is stored as Pdata
# for large documents base_data is stored as Pdata
self
.
assertIsInstance
(
document
.
base_data
,
Pdata
)
self
.
assertIsInstance
(
document
.
base_data
,
Pdata
)
...
@@ -2638,7 +2645,7 @@ return 1
...
@@ -2638,7 +2645,7 @@ return 1
# for small documents, it's bytes directly
# for small documents, it's bytes directly
document
=
self
.
portal
.
document_module
.
newContent
(
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Text'
,
portal_type
=
'Text'
,
file
=
makeFileUpload
(
'TEST-en-002.odt'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002.odt'
))
self
.
tic
()
self
.
tic
()
self
.
assertIsInstance
(
document
.
base_data
,
bytes
)
self
.
assertIsInstance
(
document
.
base_data
,
bytes
)
self
.
assertIsInstance
(
document
.
getBaseData
(),
bytes
)
self
.
assertIsInstance
(
document
.
getBaseData
(),
bytes
)
...
@@ -2650,7 +2657,7 @@ return 1
...
@@ -2650,7 +2657,7 @@ return 1
When cloning a document base_data must not be computed once again.
When cloning a document base_data must not be computed once again.
"""
"""
# create a document
# create a document
upload_file
=
makeFileUpload
(
'TEST-en-002.doc'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
self
.
tic
()
self
.
tic
()
...
@@ -2668,7 +2675,7 @@ return 1
...
@@ -2668,7 +2675,7 @@ return 1
# Update document with another content by using setData:
# Update document with another content by using setData:
# base_data must be recomputed
# base_data must be recomputed
document
.
edit
(
data
=
makeFileUpload
(
'TEST-en-002.odt'
).
read
())
document
.
edit
(
data
=
self
.
makeFileUpload
(
'TEST-en-002.odt'
).
read
())
self
.
tic
()
self
.
tic
()
self
.
assertTrue
(
document
.
hasBaseData
())
self
.
assertTrue
(
document
.
hasBaseData
())
self
.
assertNotEqual
(
previous_base_data
,
document
.
getBaseData
(),
self
.
assertNotEqual
(
previous_base_data
,
document
.
getBaseData
(),
...
@@ -2680,7 +2687,7 @@ return 1
...
@@ -2680,7 +2687,7 @@ return 1
# Update document with another content by using setFile:
# Update document with another content by using setFile:
# base_data must be recomputed
# base_data must be recomputed
document
.
edit
(
file
=
makeFileUpload
(
'TEST-en-002.doc'
))
document
.
edit
(
file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
))
self
.
tic
()
self
.
tic
()
self
.
assertTrue
(
document
.
hasBaseData
())
self
.
assertTrue
(
document
.
hasBaseData
())
self
.
assertNotEqual
(
previous_base_data
,
document
.
getBaseData
(),
self
.
assertNotEqual
(
previous_base_data
,
document
.
getBaseData
(),
...
@@ -2701,7 +2708,7 @@ return 1
...
@@ -2701,7 +2708,7 @@ return 1
back to empty state
back to empty state
"""
"""
# create a document
# create a document
upload_file
=
makeFileUpload
(
'TEST-en-002.doc'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
self
.
tic
()
self
.
tic
()
...
@@ -2849,7 +2856,7 @@ return 1
...
@@ -2849,7 +2856,7 @@ return 1
""" Test "visible" instances of a doc are auto archived when a new
""" Test "visible" instances of a doc are auto archived when a new
instance is made "visible" except when they have a future effective date.
instance is made "visible" except when they have a future effective date.
"""
"""
upload_file
=
makeFileUpload
(
'TEST-en-002.doc'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
)
document_002
=
self
.
portal
.
Base_contribute
(
**
kw
)
document_002
=
self
.
portal
.
Base_contribute
(
**
kw
)
document_002
.
publish
()
document_002
.
publish
()
...
@@ -2908,7 +2915,7 @@ return 1
...
@@ -2908,7 +2915,7 @@ return 1
self
.
tic
()
self
.
tic
()
def
testFileWithNotDefinedMimeType
(
self
):
def
testFileWithNotDefinedMimeType
(
self
):
upload_file
=
makeFileUpload
(
'TEST-001-en.dummy'
)
upload_file
=
self
.
makeFileUpload
(
'TEST-001-en.dummy'
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
,
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
,
portal_type
=
'File'
)
portal_type
=
'File'
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
...
@@ -2925,7 +2932,7 @@ return 1
...
@@ -2925,7 +2932,7 @@ return 1
Checks Base_getRelatedDocumentList works correctly with both
Checks Base_getRelatedDocumentList works correctly with both
related (follow_up) Documents and with sub-object Embedded Files
related (follow_up) Documents and with sub-object Embedded Files
"""
"""
uploaded_file
=
makeFileUpload
(
'TEST-001-en.dummy'
)
uploaded_file
=
self
.
makeFileUpload
(
'TEST-001-en.dummy'
)
document_value
=
self
.
portal
.
Base_contribute
(
document_value
=
self
.
portal
.
Base_contribute
(
file
=
uploaded_file
,
file
=
uploaded_file
,
synchronous_metadata_discovery
=
True
,
synchronous_metadata_discovery
=
True
,
...
@@ -2976,7 +2983,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
...
@@ -2976,7 +2983,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
Make sure that uploader can preview document after submitted.
Make sure that uploader can preview document after submitted.
"""
"""
filename
=
'REF-en-001.odt'
filename
=
'REF-en-001.odt'
upload_file
=
makeFileUpload
(
filename
)
upload_file
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
...
@@ -2999,9 +3006,8 @@ class TestDocumentWithSecurity(TestDocumentMixin):
...
@@ -2999,9 +3006,8 @@ class TestDocumentWithSecurity(TestDocumentMixin):
text_document
=
document_module
.
newContent
(
portal_type
=
portal_type
,
text_document
=
document_module
.
newContent
(
portal_type
=
portal_type
,
reference
=
'Foo_001'
,
reference
=
'Foo_001'
,
title
=
'Foo_OO1'
)
title
=
'Foo_OO1'
)
f
=
makeFileUpload
(
'Foo_001.odt'
)
f
=
self
.
makeFileUpload
(
'Foo_001.odt'
)
text_document
.
edit
(
file
=
f
)
text_document
.
edit
(
file
=
f
)
f
.
close
()
self
.
tic
()
self
.
tic
()
# the document should be automatically converted to html
# the document should be automatically converted to html
...
@@ -3071,14 +3077,14 @@ class TestDocumentWithSecurity(TestDocumentMixin):
...
@@ -3071,14 +3077,14 @@ class TestDocumentWithSecurity(TestDocumentMixin):
def
test_mergeRevision
(
self
):
def
test_mergeRevision
(
self
):
document1
=
self
.
portal
.
portal_contributions
.
newContent
(
document1
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'TEST-en-002.doc'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
))
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
self
.
assertEqual
(
(
document1
.
getReference
(),
document1
.
getLanguage
(),
document1
.
getVersion
()),
(
document1
.
getReference
(),
document1
.
getLanguage
(),
document1
.
getVersion
()),
(
'TEST'
,
'en'
,
'002'
))
(
'TEST'
,
'en'
,
'002'
))
self
.
assertNotIn
(
'This document is modified'
,
document1
.
asText
())
self
.
assertNotIn
(
'This document is modified'
,
document1
.
asText
())
document2
=
self
.
portal
.
portal_contributions
.
newContent
(
document2
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'TEST-en-002-modified.doc'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002-modified.doc'
))
self
.
tic
()
self
.
tic
()
self
.
assertIn
(
'This document is modified'
,
document2
.
asText
())
self
.
assertIn
(
'This document is modified'
,
document2
.
asText
())
self
.
assertEqual
(
self
.
assertEqual
(
...
@@ -3097,7 +3103,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
...
@@ -3097,7 +3103,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
with
self
.
assertRaisesRegex
(
with
self
.
assertRaisesRegex
(
Unauthorized
,
Unauthorized
,
"You are not allowed to update the existing document"
):
"You are not allowed to update the existing document"
):
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'TEST-en-002.doc'
))
self
.
portal
.
portal_contributions
.
newContent
(
file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
))
# this also works with another user which can not see the document
# this also works with another user which can not see the document
another_user_id
=
self
.
id
()
another_user_id
=
self
.
id
()
...
@@ -3107,7 +3113,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
...
@@ -3107,7 +3113,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
with
self
.
assertRaisesRegex
(
with
self
.
assertRaisesRegex
(
Unauthorized
,
Unauthorized
,
"You are not allowed to update the existing document"
):
"You are not allowed to update the existing document"
):
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'TEST-en-002.doc'
))
self
.
portal
.
portal_contributions
.
newContent
(
file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
))
def
test_mergeRevision_with_node_reference_local_reference_filename_regular_expression
(
self
):
def
test_mergeRevision_with_node_reference_local_reference_filename_regular_expression
(
self
):
# this filename regular expression comes from configurator
# this filename regular expression comes from configurator
...
@@ -3116,14 +3122,14 @@ class TestDocumentWithSecurity(TestDocumentMixin):
...
@@ -3116,14 +3122,14 @@ class TestDocumentWithSecurity(TestDocumentMixin):
)
)
self
.
tic
()
self
.
tic
()
document1
=
self
.
portal
.
portal_contributions
.
newContent
(
document1
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'TEST-en-002.doc'
,
as_name
=
'P-PROJ-TEST-002-en.doc'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
,
as_name
=
'P-PROJ-TEST-002-en.doc'
))
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
self
.
assertEqual
(
(
document1
.
getReference
(),
document1
.
getLanguage
(),
document1
.
getVersion
()),
(
document1
.
getReference
(),
document1
.
getLanguage
(),
document1
.
getVersion
()),
(
'P-PROJ-TEST'
,
'en'
,
'002'
))
(
'P-PROJ-TEST'
,
'en'
,
'002'
))
self
.
assertNotIn
(
'This document is modified'
,
document1
.
asText
())
self
.
assertNotIn
(
'This document is modified'
,
document1
.
asText
())
document2
=
self
.
portal
.
portal_contributions
.
newContent
(
document2
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'TEST-en-002-modified.doc'
,
as_name
=
'P-PROJ-TEST-002-en.doc'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002-modified.doc'
,
as_name
=
'P-PROJ-TEST-002-en.doc'
))
self
.
tic
()
self
.
tic
()
self
.
assertIn
(
'This document is modified'
,
document2
.
asText
())
self
.
assertIn
(
'This document is modified'
,
document2
.
asText
())
self
.
assertEqual
(
self
.
assertEqual
(
...
@@ -3143,7 +3149,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
...
@@ -3143,7 +3149,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
Unauthorized
,
Unauthorized
,
"You are not allowed to update the existing document"
):
"You are not allowed to update the existing document"
):
self
.
portal
.
portal_contributions
.
newContent
(
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'TEST-en-002.doc'
,
as_name
=
'P-PROJ-TEST-002-en.doc'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
,
as_name
=
'P-PROJ-TEST-002-en.doc'
))
# this also works with another user which can not see the document
# this also works with another user which can not see the document
another_user_id
=
self
.
id
()
another_user_id
=
self
.
id
()
...
@@ -3154,7 +3160,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
...
@@ -3154,7 +3160,7 @@ class TestDocumentWithSecurity(TestDocumentMixin):
Unauthorized
,
Unauthorized
,
"You are not allowed to update the existing document"
):
"You are not allowed to update the existing document"
):
self
.
portal
.
portal_contributions
.
newContent
(
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'TEST-en-002.doc'
,
as_name
=
'P-PROJ-TEST-002-en.doc'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002.doc'
,
as_name
=
'P-PROJ-TEST-002-en.doc'
))
class
TestDocumentPerformance
(
TestDocumentMixin
):
class
TestDocumentPerformance
(
TestDocumentMixin
):
...
@@ -3164,7 +3170,7 @@ class TestDocumentPerformance(TestDocumentMixin):
...
@@ -3164,7 +3170,7 @@ class TestDocumentPerformance(TestDocumentMixin):
Test large OOoDocument to image conversion
Test large OOoDocument to image conversion
"""
"""
ooo_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Spreadsheet'
)
ooo_document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Spreadsheet'
)
upload_file
=
makeFileUpload
(
'import_big_spreadsheet.ods'
)
upload_file
=
self
.
makeFileUpload
(
'import_big_spreadsheet.ods'
)
ooo_document
.
edit
(
file
=
upload_file
)
ooo_document
.
edit
(
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
before
=
time
.
time
()
before
=
time
.
time
()
...
@@ -3183,7 +3189,7 @@ class TestDocumentPerformance(TestDocumentMixin):
...
@@ -3183,7 +3189,7 @@ class TestDocumentPerformance(TestDocumentMixin):
req_time
)
req_time
)
class
DocumentConsistencyTestCase
(
ERP5Type
TestCase
):
class
DocumentConsistencyTestCase
(
DocumentUpload
TestCase
):
portal_type
=
NotImplemented
portal_type
=
NotImplemented
content_type
=
NotImplemented
content_type
=
NotImplemented
filename
=
NotImplemented
filename
=
NotImplemented
...
@@ -3193,7 +3199,7 @@ class DocumentConsistencyTestCase(ERP5TypeTestCase):
...
@@ -3193,7 +3199,7 @@ class DocumentConsistencyTestCase(ERP5TypeTestCase):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
self
.
document
=
self
.
_getDocumentModule
().
newContent
(
portal_type
=
self
.
portal_type
)
self
.
document
=
self
.
_getDocumentModule
().
newContent
(
portal_type
=
self
.
portal_type
)
self
.
file_upload
=
makeFileUpload
(
self
.
filename
)
self
.
file_upload
=
self
.
makeFileUpload
(
self
.
filename
)
with
open
(
makeFilePath
(
self
.
filename
),
'rb'
)
as
f
:
with
open
(
makeFilePath
(
self
.
filename
),
'rb'
)
as
f
:
self
.
file_data
=
f
.
read
()
self
.
file_data
=
f
.
read
()
self
.
file_size
=
len
(
self
.
file_data
)
self
.
file_size
=
len
(
self
.
file_data
)
...
...
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testOOoConversionCache.py
View file @
5afebc71
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
import
unittest
import
unittest
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
erp5.component.test.testDms
import
TestDocumentMixin
,
makeFileUpload
from
erp5.component.test.testDms
import
TestDocumentMixin
try
:
try
:
import
magic
import
magic
...
@@ -59,7 +59,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -59,7 +59,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
def
test_image_conversion
(
self
):
def
test_image_conversion
(
self
):
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
tic
()
self
.
tic
()
format_
=
'png'
format_
=
'png'
...
@@ -96,7 +96,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -96,7 +96,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
Test Conversion Cache mechanism
Test Conversion Cache mechanism
"""
"""
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
tic
()
self
.
tic
()
document_url
=
document
.
getRelativeUrl
()
document_url
=
document
.
getRelativeUrl
()
...
@@ -129,7 +129,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -129,7 +129,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
def
test_02_VolatileCacheConversionOfTempObject
(
self
):
def
test_02_VolatileCacheConversionOfTempObject
(
self
):
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
,
temp_object
=
1
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
,
temp_object
=
1
)
document
.
uploadFile
()
document
.
uploadFile
()
document
.
processFile
()
document
.
processFile
()
...
@@ -163,8 +163,8 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -163,8 +163,8 @@ class TestDocumentConversionCache(TestDocumentMixin):
def
test_03_CacheConversionOfTempObjectIsNotMixed
(
self
):
def
test_03_CacheConversionOfTempObjectIsNotMixed
(
self
):
filename1
=
'TEST-en-002.doc'
filename1
=
'TEST-en-002.doc'
filename2
=
'TEST-en-002.odt'
filename2
=
'TEST-en-002.odt'
file1
=
makeFileUpload
(
filename1
)
file1
=
self
.
makeFileUpload
(
filename1
)
file2
=
makeFileUpload
(
filename2
)
file2
=
self
.
makeFileUpload
(
filename2
)
document1
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file1
,
temp_object
=
1
)
document1
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file1
,
temp_object
=
1
)
document1
.
uploadFile
()
document1
.
uploadFile
()
document1
.
processFile
()
document1
.
processFile
()
...
@@ -187,7 +187,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -187,7 +187,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
self
.
portal
.
portal_caches
.
clearAllCache
()
self
.
portal
.
portal_caches
.
clearAllCache
()
self
.
tic
()
self
.
tic
()
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
tic
()
self
.
tic
()
document_url
=
document
.
getRelativeUrl
()
document_url
=
document
.
getRelativeUrl
()
...
@@ -223,7 +223,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -223,7 +223,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
Test Conversion Cache return expected value with checksum
Test Conversion Cache return expected value with checksum
"""
"""
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
tic
()
self
.
tic
()
document_url
=
document
.
getRelativeUrl
()
document_url
=
document
.
getRelativeUrl
()
...
@@ -252,7 +252,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -252,7 +252,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
Check that md5 checksum is well updated when upload a file
Check that md5 checksum is well updated when upload a file
"""
"""
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
tic
()
self
.
tic
()
document_url
=
document
.
getRelativeUrl
()
document_url
=
document
.
getRelativeUrl
()
...
@@ -260,7 +260,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -260,7 +260,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
md5sum
=
document
.
getContentMd5
()
md5sum
=
document
.
getContentMd5
()
self
.
assertTrue
(
md5sum
)
self
.
assertTrue
(
md5sum
)
filename2
=
'TEST-en-002.odt'
filename2
=
'TEST-en-002.odt'
file2
=
makeFileUpload
(
filename2
)
file2
=
self
.
makeFileUpload
(
filename2
)
document
.
edit
(
file
=
file2
)
document
.
edit
(
file
=
file2
)
self
.
assertNotEqual
(
md5sum
,
document
.
getContentMd5
())
self
.
assertNotEqual
(
md5sum
,
document
.
getContentMd5
())
self
.
tic
()
self
.
tic
()
...
@@ -275,7 +275,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -275,7 +275,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
self
.
portal
.
portal_caches
.
clearAllCache
()
self
.
portal
.
portal_caches
.
clearAllCache
()
self
.
tic
()
self
.
tic
()
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document_id
=
'an id with spaces'
document_id
=
'an id with spaces'
portal_type
=
'Text'
portal_type
=
'Text'
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
module
=
self
.
portal
.
getDefaultModule
(
portal_type
)
...
@@ -314,7 +314,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
...
@@ -314,7 +314,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
self
.
assertEqual
(
len
(
portal_type_list
),
len
([
pt
for
pt
in
portal_type_list
if
pt
in
data_mapping
]))
self
.
assertEqual
(
len
(
portal_type_list
),
len
([
pt
for
pt
in
portal_type_list
if
pt
in
data_mapping
]))
for
portal_type
in
portal_type_list
:
for
portal_type
in
portal_type_list
:
module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
portal_type
)
module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
portal_type
)
upload_file
=
makeFileUpload
(
data_mapping
[
portal_type
])
upload_file
=
self
.
makeFileUpload
(
data_mapping
[
portal_type
])
document
=
module
.
newContent
(
portal_type
=
portal_type
)
document
=
module
.
newContent
(
portal_type
=
portal_type
)
document
.
edit
(
file
=
upload_file
)
document
.
edit
(
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
...
...
bt5/erp5_dms/TestTemplateItem/portal_components/test.erp5.testOOoConversionServerRetry.py
View file @
5afebc71
...
@@ -25,12 +25,11 @@
...
@@ -25,12 +25,11 @@
#
#
##############################################################################
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
erp5.component.test.testDms
import
DocumentUploadTestCase
from
erp5.component.test.testDms
import
makeFileUpload
from
Products.ERP5Form.PreferenceTool
import
Priority
from
Products.ERP5Form.PreferenceTool
import
Priority
class
TestOOoConversionServerRetry
(
ERP5Type
TestCase
):
class
TestOOoConversionServerRetry
(
DocumentUpload
TestCase
):
def
getBusinessTemplateList
(
self
):
def
getBusinessTemplateList
(
self
):
business_template_list
=
[
'erp5_core_proxy_field_legacy'
,
business_template_list
=
[
'erp5_core_proxy_field_legacy'
,
'erp5_jquery'
,
'erp5_jquery'
,
...
@@ -80,7 +79,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase):
...
@@ -80,7 +79,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase):
self
.
tic
()
self
.
tic
()
filename
=
'monochrome_sample.tiff'
filename
=
'monochrome_sample.tiff'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Text'
)
document
=
self
.
portal
.
document_module
.
newContent
(
portal_type
=
'Text'
)
document
.
edit
(
file
=
file_
)
document
.
edit
(
file
=
file_
)
message
=
document
.
Document_tryToConvertToBaseFormat
()
message
=
document
.
Document_tryToConvertToBaseFormat
()
...
@@ -95,7 +94,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase):
...
@@ -95,7 +94,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase):
system_pref
.
setPreferredDocumentConversionServerUrlList
([
'https://broken.url'
])
system_pref
.
setPreferredDocumentConversionServerUrlList
([
'https://broken.url'
])
self
.
tic
()
self
.
tic
()
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
message
=
document
.
Document_tryToConvertToBaseFormat
()
message
=
document
.
Document_tryToConvertToBaseFormat
()
...
@@ -110,7 +109,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase):
...
@@ -110,7 +109,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase):
system_pref
.
setPreferredOoodocServerTimeout
(
1
)
system_pref
.
setPreferredOoodocServerTimeout
(
1
)
self
.
tic
()
self
.
tic
()
filename
=
'TEST-en-002.doc'
filename
=
'TEST-en-002.doc'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
message
=
document
.
Document_tryToConvertToBaseFormat
()
message
=
document
.
Document_tryToConvertToBaseFormat
()
...
...
bt5/erp5_dms_conversion_catalog/TestTemplateItem/portal_components/test.erp5.testDmsWithPreConversion.py
View file @
5afebc71
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
##############################################################################
##############################################################################
import
unittest
import
unittest
from
erp5.component.test.testDms
import
TestDocument
,
makeFileUpload
from
erp5.component.test.testDms
import
TestDocument
class
TestDocumentWithPreConversion
(
TestDocument
):
class
TestDocumentWithPreConversion
(
TestDocument
):
"""
"""
...
@@ -40,7 +40,7 @@ class TestDocumentWithPreConversion(TestDocument):
...
@@ -40,7 +40,7 @@ class TestDocumentWithPreConversion(TestDocument):
def
test_preConvertedReferencedImageInWebPageContent
(
self
):
def
test_preConvertedReferencedImageInWebPageContent
(
self
):
# create an image
# create an image
upload_file
=
makeFileUpload
(
'cmyk_sample.jpg'
)
upload_file
=
self
.
makeFileUpload
(
'cmyk_sample.jpg'
)
image
=
self
.
portal
.
image_module
.
newContent
(
portal_type
=
'Image'
,
image
=
self
.
portal
.
image_module
.
newContent
(
portal_type
=
'Image'
,
reference
=
'Embedded-XXX'
,
reference
=
'Embedded-XXX'
,
version
=
'001'
,
version
=
'001'
,
...
@@ -75,7 +75,7 @@ class TestDocumentWithPreConversion(TestDocument):
...
@@ -75,7 +75,7 @@ class TestDocumentWithPreConversion(TestDocument):
language
=
'en'
)
language
=
'en'
)
# draft image is not convertible
# draft image is not convertible
upload_file
=
makeFileUpload
(
'cmyk_sample.jpg'
)
upload_file
=
self
.
makeFileUpload
(
'cmyk_sample.jpg'
)
image
.
edit
(
file
=
upload_file
)
image
.
edit
(
file
=
upload_file
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
False
,
image
.
Base_isConvertible
())
self
.
assertEqual
(
False
,
image
.
Base_isConvertible
())
...
...
bt5/erp5_km/TestTemplateItem/portal_components/test.erp5.testKM.py
View file @
5afebc71
...
@@ -31,7 +31,7 @@ import unittest
...
@@ -31,7 +31,7 @@ import unittest
from
unittest
import
expectedFailure
from
unittest
import
expectedFailure
from
AccessControl.SecurityManagement
import
newSecurityManager
from
AccessControl.SecurityManagement
import
newSecurityManager
from
Products.ERP5Type.Base
import
TempBase
from
Products.ERP5Type.Base
import
TempBase
from
erp5.component.test.testDms
import
makeFileUpload
,
TestDocumentMixin
from
erp5.component.test.testDms
import
TestDocumentMixin
def
_getGadgetInstanceUrlFromKnowledgePad
(
knowledge_pad
,
gadget
):
def
_getGadgetInstanceUrlFromKnowledgePad
(
knowledge_pad
,
gadget
):
""" Get Knowledge Box's relative URL specialising a gadget in a Knowledge Pad."""
""" Get Knowledge Box's relative URL specialising a gadget in a Knowledge Pad."""
...
@@ -39,6 +39,7 @@ def _getGadgetInstanceUrlFromKnowledgePad(knowledge_pad, gadget):
...
@@ -39,6 +39,7 @@ def _getGadgetInstanceUrlFromKnowledgePad(knowledge_pad, gadget):
portal_type
=
'Knowledge Box'
,
portal_type
=
'Knowledge Box'
,
specialise_uid
=
gadget
.
getUid
())[
0
].
getObject
().
getRelativeUrl
()
specialise_uid
=
gadget
.
getUid
())[
0
].
getObject
().
getRelativeUrl
()
class
TestKMMixIn
(
TestDocumentMixin
):
class
TestKMMixIn
(
TestDocumentMixin
):
"""
"""
Mix in class for Knowledge Management system.
Mix in class for Knowledge Management system.
...
@@ -1008,38 +1009,38 @@ class TestKMSearch(TestKMMixIn):
...
@@ -1008,38 +1009,38 @@ class TestKMSearch(TestKMMixIn):
# create docs to be referenced:
# create docs to be referenced:
# (1) TEST, 002, en
# (1) TEST, 002, en
filename
=
'TEST-en-002.odt'
filename
=
'TEST-en-002.odt'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# (2) TEST, 002, fr
# (2) TEST, 002, fr
as_name
=
'TEST-fr-002.odt'
as_name
=
'TEST-fr-002.odt'
file_
=
makeFileUpload
(
filename
,
as_name
)
file_
=
self
.
makeFileUpload
(
filename
,
as_name
)
document2
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document2
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# (3) TEST, 003, en
# (3) TEST, 003, en
as_name
=
'TEST-en-003.odt'
as_name
=
'TEST-en-003.odt'
file_
=
makeFileUpload
(
filename
,
as_name
)
file_
=
self
.
makeFileUpload
(
filename
,
as_name
)
document3
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document3
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# create docs to contain references in text_content:
# create docs to contain references in text_content:
# REF, 002, en; "I use reference to look up TEST"
# REF, 002, en; "I use reference to look up TEST"
filename
=
'REF-en-002.odt'
filename
=
'REF-en-002.odt'
file_
=
makeFileUpload
(
filename
)
file_
=
self
.
makeFileUpload
(
filename
)
document5
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
document5
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
file_
)
# REFLANG, 001, en: "I use reference and language to look up TEST-fr"
# REFLANG, 001, en: "I use reference and language to look up TEST-fr"
#filename = 'REFLANG-en-001.odt'
#filename = 'REFLANG-en-001.odt'
#file = makeFileUpload(filename)
#file =
self.
makeFileUpload(filename)
#document6 = self.portal.portal_contributions.newContent(file=file)
#document6 = self.portal.portal_contributions.newContent(file=file)
# REFVER, 001, en: "I use reference and version to look up TEST-002"
# REFVER, 001, en: "I use reference and version to look up TEST-002"
#filename = 'REFVER-en-001.odt'
#filename = 'REFVER-en-001.odt'
#file = makeFileUpload(filename)
#file =
self.
makeFileUpload(filename)
#document7 = self.portal.portal_contributions.newContent(file=file)
#document7 = self.portal.portal_contributions.newContent(file=file)
# REFVERLANG, 001, en: "I use reference, version and language to look up TEST-002-en"
# REFVERLANG, 001, en: "I use reference, version and language to look up TEST-002-en"
#filename = 'REFVERLANG-en-001.odt'
#filename = 'REFVERLANG-en-001.odt'
#file = makeFileUpload(filename)
#file =
self.
makeFileUpload(filename)
#document8 = self.portal.portal_contributions.newContent(file=file)
#document8 = self.portal.portal_contributions.newContent(file=file)
self
.
tic
()
self
.
tic
()
...
...
bt5/erp5_pdf_merge/TestTemplateItem/portal_components/test.erp5.testERP5PDFMerge.py
View file @
5afebc71
...
@@ -26,11 +26,11 @@
...
@@ -26,11 +26,11 @@
##############################################################################
##############################################################################
import
warnings
import
warnings
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
erp5.component.test.testDms
import
DocumentUploadTestCase
from
erp5.component.test.testDms
import
makeFileUpload
from
Products.ERP5Type
import
Utils
from
Products.ERP5Type
import
Utils
class
TestERP5PDFMerge
(
ERP5TypeTestCase
):
class
TestERP5PDFMerge
(
DocumentUploadTestCase
):
def
test_showwarning_issue
(
self
):
def
test_showwarning_issue
(
self
):
"""
"""
...
@@ -39,7 +39,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase):
...
@@ -39,7 +39,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase):
"""
"""
self
.
assertEqual
(
Utils
.
_showwarning
,
warnings
.
showwarning
)
self
.
assertEqual
(
Utils
.
_showwarning
,
warnings
.
showwarning
)
document
=
self
.
portal
.
portal_contributions
.
newContent
(
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'REF-en-001.pdf'
))
file
=
self
.
makeFileUpload
(
'REF-en-001.pdf'
))
merged_pdf_data
=
self
.
portal
.
ERP5Site_mergePDFList
(
merged_pdf_data
=
self
.
portal
.
ERP5Site_mergePDFList
(
[
document
.
getData
(),
document
.
getData
()])
[
document
.
getData
(),
document
.
getData
()])
self
.
portal
.
document_module
.
newContent
(
self
.
portal
.
document_module
.
newContent
(
...
@@ -50,7 +50,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase):
...
@@ -50,7 +50,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase):
def
test_erp5_merge_pdf
(
self
):
def
test_erp5_merge_pdf
(
self
):
document
=
self
.
portal
.
portal_contributions
.
newContent
(
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'REF-en-001.pdf'
))
file
=
self
.
makeFileUpload
(
'REF-en-001.pdf'
))
merged_pdf_data
=
self
.
portal
.
ERP5Site_mergePDFList
(
merged_pdf_data
=
self
.
portal
.
ERP5Site_mergePDFList
(
[
document
.
getData
(),
document
.
getData
()])
[
document
.
getData
(),
document
.
getData
()])
merged_document
=
self
.
portal
.
document_module
.
newContent
(
merged_document
=
self
.
portal
.
document_module
.
newContent
(
...
@@ -60,7 +60,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase):
...
@@ -60,7 +60,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase):
def
test_erp5_merge_pdf_start_on_recto
(
self
):
def
test_erp5_merge_pdf_start_on_recto
(
self
):
document
=
self
.
portal
.
portal_contributions
.
newContent
(
document
=
self
.
portal
.
portal_contributions
.
newContent
(
file
=
makeFileUpload
(
'REF-en-001.pdf'
))
file
=
self
.
makeFileUpload
(
'REF-en-001.pdf'
))
merged_pdf_data
=
self
.
portal
.
ERP5Site_mergePDFList
(
merged_pdf_data
=
self
.
portal
.
ERP5Site_mergePDFList
(
[
document
.
getData
(),
document
.
getData
()],
start_on_recto
=
True
)
[
document
.
getData
(),
document
.
getData
()],
start_on_recto
=
True
)
merged_document
=
self
.
portal
.
document_module
.
newContent
(
merged_document
=
self
.
portal
.
document_module
.
newContent
(
...
...
bt5/erp5_run_my_doc/TestTemplateItem/portal_components/test.erp5.testRunMyDoc.py
View file @
5afebc71
...
@@ -26,12 +26,12 @@
...
@@ -26,12 +26,12 @@
#
#
##############################################################################
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
erp5.component.test.testDms
import
DocumentUploadTestCase
from
erp5.component.test.testDms
import
makeFileUpload
from
time
import
time
from
time
import
time
import
base64
import
base64
class
TestRunMyDoc
(
ERP5TypeTestCase
):
class
TestRunMyDoc
(
DocumentUploadTestCase
):
"""
"""
Basic Test for internal implementation of RunMyDocs
Basic Test for internal implementation of RunMyDocs
"""
"""
...
@@ -96,7 +96,7 @@ class TestRunMyDoc(ERP5TypeTestCase):
...
@@ -96,7 +96,7 @@ class TestRunMyDoc(ERP5TypeTestCase):
Test Screeshot upload script used by Zelenium to
Test Screeshot upload script used by Zelenium to
update screenshots of the documents.
update screenshots of the documents.
"""
"""
image_upload
=
makeFileUpload
(
'TEST-en-002.png'
)
image_upload
=
self
.
makeFileUpload
(
'TEST-en-002.png'
)
self
.
assertNotEqual
(
None
,
image_upload
)
self
.
assertNotEqual
(
None
,
image_upload
)
# Create a web page, and check if the content is not overwriten
# Create a web page, and check if the content is not overwriten
...
...
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