Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
erp5
Commits
ba6eef59
Commit
ba6eef59
authored
Jul 28, 2023
by
Emmy Vouriot
Committed by
Jérome Perrin
Feb 01, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: specify read files are bytes not str
parent
7cc89c6e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
24 deletions
+42
-24
product/ERP5OOo/tests/testIngestion.py
product/ERP5OOo/tests/testIngestion.py
+42
-24
No files found.
product/ERP5OOo/tests/testIngestion.py
View file @
ba6eef59
...
@@ -52,6 +52,7 @@ import ZPublisher.HTTPRequest
...
@@ -52,6 +52,7 @@ import ZPublisher.HTTPRequest
from
unittest
import
expectedFailure
from
unittest
import
expectedFailure
import
six.moves.http_client
import
six.moves.http_client
import
six.moves.urllib.parse
,
six
.
moves
.
urllib
.
request
import
six.moves.urllib.parse
,
six
.
moves
.
urllib
.
request
import
six
import
base64
import
base64
...
@@ -756,33 +757,50 @@ class TestIngestion(IngestionTestCase):
...
@@ -756,33 +757,50 @@ class TestIngestion(IngestionTestCase):
document
=
self
.
portal
.
restrictedTraverse
(
sequence
.
get
(
'document_path'
))
document
=
self
.
portal
.
restrictedTraverse
(
sequence
.
get
(
'document_path'
))
self
.
checkDocumentExportList
(
document
,
'doc'
,
self
.
checkDocumentExportList
(
document
,
'doc'
,
[
'pdf'
,
'doc'
,
'rtf'
,
'txt'
,
'odt'
])
[
'pdf'
,
'doc'
,
'rtf'
,
'txt'
,
'odt'
])
# legacy format will be replaced
if
six
.
PY2
:
expectedFailure
(
self
.
checkDocumentExportList
)(
document
,
'doc'
,
# legacy format will be replaced
[
'writer.html'
])
expectedFailure
(
self
.
checkDocumentExportList
)(
document
,
'doc'
,
[
'writer.html'
])
else
:
self
.
assertRaises
(
AssertionError
,
self
.
checkDocumentExportList
,
document
,
'doc'
,
[
'writer.html'
])
def
stepCheckSpreadsheetDocumentExportList
(
self
,
sequence
=
None
,
def
stepCheckSpreadsheetDocumentExportList
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
document
=
self
.
portal
.
restrictedTraverse
(
sequence
.
get
(
'document_path'
))
document
=
self
.
portal
.
restrictedTraverse
(
sequence
.
get
(
'document_path'
))
self
.
checkDocumentExportList
(
document
,
'xls'
,
[
'csv'
,
'xls'
,
'ods'
,
'pdf'
])
self
.
checkDocumentExportList
(
document
,
'xls'
,
[
'csv'
,
'xls'
,
'ods'
,
'pdf'
])
# legacy format will be replaced
if
six
.
PY2
:
expectedFailure
(
self
.
checkDocumentExportList
)(
document
,
'xls'
,
# legacy format will be replaced
[
'calc.html'
,
'calc.pdf'
])
expectedFailure
(
self
.
checkDocumentExportList
)(
document
,
'xls'
,
[
'calc.html'
,
'calc.pdf'
])
else
:
self
.
assertRaises
(
AssertionError
,
self
.
checkDocumentExportList
,
document
,
'xls'
,
[
'calc.html'
,
'calc.pdf'
])
def
stepCheckPresentationDocumentExportList
(
self
,
sequence
=
None
,
def
stepCheckPresentationDocumentExportList
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
document
=
self
.
portal
.
restrictedTraverse
(
sequence
.
get
(
'document_path'
))
document
=
self
.
portal
.
restrictedTraverse
(
sequence
.
get
(
'document_path'
))
self
.
checkDocumentExportList
(
document
,
'ppt'
,
[
'ppt'
,
'odp'
,
'pdf'
])
self
.
checkDocumentExportList
(
document
,
'ppt'
,
[
'ppt'
,
'odp'
,
'pdf'
])
# legacy format will be replaced
if
six
.
PY2
:
expectedFailure
(
self
.
checkDocumentExportList
)(
document
,
# legacy format will be replaced
'ppt'
,
[
'impr.pdf'
])
expectedFailure
(
self
.
checkDocumentExportList
)(
document
,
'ppt'
,
[
'impr.pdf'
])
else
:
self
.
assertRaises
(
AssertionError
,
self
.
checkDocumentExportList
,
document
,
'ppt'
,
[
'impr.pdf'
])
def
stepCheckDrawingDocumentExportList
(
self
,
sequence
=
None
,
def
stepCheckDrawingDocumentExportList
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
document
=
self
.
portal
.
restrictedTraverse
(
sequence
.
get
(
'document_path'
))
document
=
self
.
portal
.
restrictedTraverse
(
sequence
.
get
(
'document_path'
))
self
.
checkDocumentExportList
(
document
,
'sxd'
,
[
'jpg'
,
'svg'
,
'pdf'
,
'odg'
])
self
.
checkDocumentExportList
(
document
,
'sxd'
,
[
'jpg'
,
'svg'
,
'pdf'
,
'odg'
])
# legacy format will be replaced
if
six
.
PY2
:
expectedFailure
(
self
.
checkDocumentExportList
)(
document
,
# legacy format will be replaced
expectedFailure
(
self
.
checkDocumentExportList
)(
document
,
'sxd'
,
[
'draw.pdf'
])
'sxd'
,
[
'draw.pdf'
])
else
:
self
.
assertRaises
(
AssertionError
,
self
.
checkDocumentExportList
,
document
,
'sxd'
,
[
'draw.pdf'
])
def
stepExportPDF
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepExportPDF
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
"""
"""
...
@@ -792,10 +810,10 @@ class TestIngestion(IngestionTestCase):
...
@@ -792,10 +810,10 @@ class TestIngestion(IngestionTestCase):
f
=
makeFileUpload
(
'TEST-en-002.pdf'
)
f
=
makeFileUpload
(
'TEST-en-002.pdf'
)
document
.
edit
(
file
=
f
)
document
.
edit
(
file
=
f
)
mime
,
text
=
document
.
convert
(
'text'
)
mime
,
text
=
document
.
convert
(
'text'
)
self
.
assertIn
(
'magic'
,
text
)
self
.
assertIn
(
b
'magic'
,
text
)
self
.
assertTrue
(
mime
==
'text/plain'
)
self
.
assertTrue
(
mime
==
'text/plain'
)
mime
,
html
=
document
.
convert
(
'html'
)
mime
,
html
=
document
.
convert
(
'html'
)
self
.
assertIn
(
'magic'
,
html
)
self
.
assertIn
(
b
'magic'
,
html
)
self
.
assertTrue
(
mime
==
'text/html'
)
self
.
assertTrue
(
mime
==
'text/html'
)
def
stepExportImage
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepExportImage
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
...
@@ -932,7 +950,7 @@ class TestIngestion(IngestionTestCase):
...
@@ -932,7 +950,7 @@ class TestIngestion(IngestionTestCase):
"""
"""
Email was sent in by someone to ERP5.
Email was sent in by someone to ERP5.
"""
"""
f
=
open
(
makeFilePath
(
'email_from.txt'
))
f
=
open
(
makeFilePath
(
'email_from.txt'
)
,
"rb"
)
document
=
self
.
receiveEmail
(
f
.
read
())
document
=
self
.
receiveEmail
(
f
.
read
())
self
.
tic
()
self
.
tic
()
...
@@ -941,7 +959,7 @@ class TestIngestion(IngestionTestCase):
...
@@ -941,7 +959,7 @@ class TestIngestion(IngestionTestCase):
"""
"""
Email was sent in by someone to ERP5.
Email was sent in by someone to ERP5.
"""
"""
f
=
open
(
makeFilePath
(
'email_multiple_attachments.eml'
))
f
=
open
(
makeFilePath
(
'email_multiple_attachments.eml'
)
,
"rb"
)
document
=
self
.
receiveEmail
(
f
.
read
())
document
=
self
.
receiveEmail
(
f
.
read
())
self
.
tic
()
self
.
tic
()
...
@@ -1540,7 +1558,7 @@ return result
...
@@ -1540,7 +1558,7 @@ return result
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
portal_type
=
'File'
,
portal_type
=
'File'
,
filename
=
'toto.txt'
,
filename
=
'toto.txt'
,
data
=
'Hello World!'
)
data
=
b
'Hello World!'
)
document_to_ingest
.
publish
()
document_to_ingest
.
publish
()
self
.
tic
()
self
.
tic
()
url
=
document_to_ingest
.
absolute_url
()
+
'/getData'
url
=
document_to_ingest
.
absolute_url
()
+
'/getData'
...
@@ -1618,7 +1636,7 @@ return result
...
@@ -1618,7 +1636,7 @@ return result
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
portal_type
=
'File'
,
portal_type
=
'File'
,
filename
=
'toto.txt'
,
filename
=
'toto.txt'
,
data
=
'Hello World!'
)
data
=
b
'Hello World!'
)
document_to_ingest
.
publish
()
document_to_ingest
.
publish
()
self
.
tic
()
self
.
tic
()
url
=
document_to_ingest
.
absolute_url
()
+
'/getData'
url
=
document_to_ingest
.
absolute_url
()
+
'/getData'
...
@@ -1676,7 +1694,7 @@ context.setReference(reference)
...
@@ -1676,7 +1694,7 @@ context.setReference(reference)
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
portal_type
=
'File'
,
portal_type
=
'File'
,
filename
=
'toto.txt'
,
filename
=
'toto.txt'
,
data
=
'Hello World!'
)
data
=
b
'Hello World!'
)
document_to_ingest
.
publish
()
document_to_ingest
.
publish
()
self
.
tic
()
self
.
tic
()
url
=
document_to_ingest
.
absolute_url
()
+
'/getData'
url
=
document_to_ingest
.
absolute_url
()
+
'/getData'
...
@@ -1767,7 +1785,7 @@ return result
...
@@ -1767,7 +1785,7 @@ return result
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
portal_type
=
'File'
,
portal_type
=
'File'
,
filename
=
'toto.txt'
,
filename
=
'toto.txt'
,
data
=
'Hello World!'
)
data
=
b
'Hello World!'
)
document_to_ingest
.
publish
()
document_to_ingest
.
publish
()
self
.
tic
()
self
.
tic
()
url
=
document_to_ingest
.
absolute_url
()
+
'/getData'
url
=
document_to_ingest
.
absolute_url
()
+
'/getData'
...
@@ -1856,7 +1874,7 @@ return result
...
@@ -1856,7 +1874,7 @@ return result
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
document_to_ingest
=
self
.
portal
.
portal_contributions
.
newContent
(
portal_type
=
'File'
,
portal_type
=
'File'
,
filename
=
'toto.txt'
,
filename
=
'toto.txt'
,
data
=
'Hello World!'
)
data
=
b
'Hello World!'
)
document_to_ingest
.
publish
()
document_to_ingest
.
publish
()
self
.
tic
()
self
.
tic
()
...
@@ -1907,7 +1925,7 @@ return result
...
@@ -1907,7 +1925,7 @@ return result
a Spreadsheet ?
a Spreadsheet ?
"""
"""
path
=
makeFilePath
(
'import_region_category.ods'
)
path
=
makeFilePath
(
'import_region_category.ods'
)
data
=
open
(
path
,
'r'
).
read
()
data
=
open
(
path
,
'r
b
'
).
read
()
document
=
self
.
portal
.
portal_contributions
.
newContent
(
filename
=
'toto'
,
document
=
self
.
portal
.
portal_contributions
.
newContent
(
filename
=
'toto'
,
data
=
data
,
data
=
data
,
...
@@ -1960,7 +1978,7 @@ return result
...
@@ -1960,7 +1978,7 @@ return result
"""Check that given portal_type is always honoured
"""Check that given portal_type is always honoured
"""
"""
path
=
makeFilePath
(
'import_region_category.xls'
)
path
=
makeFilePath
(
'import_region_category.xls'
)
data
=
open
(
path
,
'r'
).
read
()
data
=
open
(
path
,
'r
b
'
).
read
()
document
=
self
.
portal
.
portal_contributions
.
newContent
(
document
=
self
.
portal
.
portal_contributions
.
newContent
(
filename
=
'import_region_category.xls'
,
filename
=
'import_region_category.xls'
,
...
@@ -1978,7 +1996,7 @@ return result
...
@@ -1978,7 +1996,7 @@ return result
"""Check that given id is always honoured
"""Check that given id is always honoured
"""
"""
path
=
makeFilePath
(
'import_region_category.xls'
)
path
=
makeFilePath
(
'import_region_category.xls'
)
data
=
open
(
path
,
'r'
).
read
()
data
=
open
(
path
,
'r
b
'
).
read
()
document
=
self
.
portal
.
portal_contributions
.
newContent
(
document
=
self
.
portal
.
portal_contributions
.
newContent
(
id
=
'this_id'
,
id
=
'this_id'
,
...
@@ -2003,7 +2021,7 @@ return result
...
@@ -2003,7 +2021,7 @@ return result
def
test_newContent_trough_http
(
self
):
def
test_newContent_trough_http
(
self
):
filename
=
'import_region_category.xls'
filename
=
'import_region_category.xls'
path
=
makeFilePath
(
filename
)
path
=
makeFilePath
(
filename
)
data
=
open
(
path
,
'r'
).
read
()
data
=
open
(
path
,
'r
b
'
).
read
()
reference
=
'ITISAREFERENCE'
reference
=
'ITISAREFERENCE'
portal_url
=
self
.
portal
.
absolute_url
()
portal_url
=
self
.
portal
.
absolute_url
()
...
...
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