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
c9200d3e
Commit
c9200d3e
authored
Jan 30, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testIngestion
parent
6a1bed2b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
product/ERP5OOo/tests/testIngestion.py
product/ERP5OOo/tests/testIngestion.py
+17
-17
No files found.
product/ERP5OOo/tests/testIngestion.py
View file @
c9200d3e
...
...
@@ -811,11 +811,11 @@ class TestIngestion(IngestionTestCase):
f
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
)
document
.
edit
(
file
=
f
)
mime
,
text
=
document
.
convert
(
'text'
)
self
.
assertIn
(
b
'magic'
,
text
)
self
.
assert
True
(
mime
==
'text/plain'
)
self
.
assertIn
(
'magic'
,
text
)
self
.
assert
Equal
(
mime
,
'text/plain'
)
mime
,
html
=
document
.
convert
(
'html'
)
self
.
assertIn
(
b
'magic'
,
html
)
self
.
assert
True
(
mime
==
'text/html'
)
self
.
assertIn
(
'magic'
,
html
)
self
.
assert
Equal
(
mime
,
'text/html'
)
def
stepExportImage
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
"""
...
...
@@ -2035,15 +2035,16 @@ return result
hostname
=
url_split
[
1
])
uri
=
'%(protocol)s://%(hostname)s'
%
url_dict
# TODO: this can not be supported on python3, switch to multipart content type
push_url
=
'%s%s/newContent'
%
(
uri
,
self
.
portal
.
portal_contributions
.
getPath
(),)
request
=
six
.
moves
.
urllib
.
request
.
Request
(
push_url
,
str2bytes
(
six
.
moves
.
urllib
.
parse
.
urlencode
(
{
'data'
:
data
,
{
'data
:bytes
'
:
data
,
'filename'
:
filename
,
'reference'
:
reference
,
'disable_cookie_login__'
:
1
,
})),
headers
=
{
'Authorization'
:
'Basic %s'
%
base64
.
b64encode
(
b'ERP5TypeTestCase:'
)
base64
.
b64encode
(
b'ERP5TypeTestCase:'
)
.
decode
()
})
# disable_cookie_login__ is required to force zope to raise Unauthorized (401)
# then HTTPDigestAuthHandler can perform HTTP Authentication
...
...
@@ -2136,11 +2137,10 @@ class Base_contributeMixin:
Test contributing an empty file and attaching it to context.
"""
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
empty_file_upload
=
ZPublisher
.
HTTPRequest
.
FileUpload
(
FieldStorage
(
fp
=
io
.
BytesIO
(),
environ
=
dict
(
REQUEST_METHOD
=
'PUT'
),
headers
=
{
"content-disposition"
:
"attachment; filename=empty;"
}))
class
FileUpload
(
io
.
BytesIO
):
filename
=
"empty"
headers
=
{}
empty_file_upload
=
FileUpload
(
b""
)
contributed_document
=
person
.
Base_contribute
(
portal_type
=
None
,
...
...
@@ -2304,7 +2304,7 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
))
self
.
assertIn
(
(
'portal_status_message'
,
'PDF created successfully.'
),
urlparse
.
parse_qsl
(
url
parse
.
urlparse
(
ret
).
query
))
six
.
moves
.
urllib
.
parse
.
parse_qsl
(
six
.
moves
.
urllib
.
parse
.
urlparse
(
ret
).
query
))
document
,
=
self
.
portal
.
document_module
.
contentValues
()
self
.
assertEqual
(
...
...
@@ -2322,7 +2322,7 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
))
self
.
assertIn
(
(
'portal_status_message'
,
'PDF updated successfully.'
),
urlparse
.
parse_qsl
(
url
parse
.
urlparse
(
ret
).
query
))
six
.
moves
.
urllib
.
parse
.
parse_qsl
(
six
.
moves
.
urllib
.
parse
.
urlparse
(
ret
).
query
))
document
,
=
self
.
portal
.
document_module
.
contentValues
()
self
.
assertEqual
(
...
...
@@ -2346,10 +2346,10 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
self
.
assertIn
(
(
'portal_status_message'
,
'You are not allowed to update the existing document which has the same coordinates.'
),
urlparse
.
parse_qsl
(
url
parse
.
urlparse
(
str
(
ctx
.
exception
)).
query
))
six
.
moves
.
urllib
.
parse
.
parse_qsl
(
six
.
moves
.
urllib
.
parse
.
urlparse
(
str
(
ctx
.
exception
)).
query
))
self
.
assertIn
(
(
'portal_status_level'
,
'error'
),
urlparse
.
parse_qsl
(
url
parse
.
urlparse
(
str
(
ctx
.
exception
)).
query
))
six
.
moves
.
urllib
.
parse
.
parse_qsl
(
six
.
moves
.
urllib
.
parse
.
urlparse
(
str
(
ctx
.
exception
)).
query
))
# document is not updated
self
.
assertEqual
(
document
.
getData
(),
b''
)
...
...
@@ -2383,10 +2383,10 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
))
self
.
assertIn
(
(
'portal_status_message'
,
'You are not allowed to contribute document in that state.'
),
urlparse
.
parse_qsl
(
url
parse
.
urlparse
(
str
(
ctx
.
exception
)).
query
))
six
.
moves
.
urllib
.
parse
.
parse_qsl
(
six
.
moves
.
urllib
.
parse
.
urlparse
(
str
(
ctx
.
exception
)).
query
))
self
.
assertIn
(
(
'portal_status_level'
,
'error'
),
urlparse
.
parse_qsl
(
url
parse
.
urlparse
(
str
(
ctx
.
exception
)).
query
))
six
.
moves
.
urllib
.
parse
.
parse_qsl
(
six
.
moves
.
urllib
.
parse
.
urlparse
(
str
(
ctx
.
exception
)).
query
))
# when using the script directly it's an error
with
self
.
assertRaisesRegex
(
...
...
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