Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
141
Merge Requests
141
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
80aec86a
Commit
80aec86a
authored
Jan 30, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testIngestion
parent
d416d94b
Changes
1
Hide 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 @
80aec86a
...
@@ -819,11 +819,11 @@ class TestIngestion(IngestionTestCase):
...
@@ -819,11 +819,11 @@ class TestIngestion(IngestionTestCase):
f
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
)
f
=
self
.
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
(
b
'magic'
,
text
)
self
.
assertIn
(
'magic'
,
text
)
self
.
assert
True
(
mime
==
'text/plain'
)
self
.
assert
Equal
(
mime
,
'text/plain'
)
mime
,
html
=
document
.
convert
(
'html'
)
mime
,
html
=
document
.
convert
(
'html'
)
self
.
assertIn
(
b
'magic'
,
html
)
self
.
assertIn
(
'magic'
,
html
)
self
.
assert
True
(
mime
==
'text/html'
)
self
.
assert
Equal
(
mime
,
'text/html'
)
def
stepExportImage
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepExportImage
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
"""
"""
...
@@ -2071,15 +2071,16 @@ return result
...
@@ -2071,15 +2071,16 @@ return result
hostname
=
url_split
[
1
])
hostname
=
url_split
[
1
])
uri
=
'%(protocol)s://%(hostname)s'
%
url_dict
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
(),)
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
(
request
=
six
.
moves
.
urllib
.
request
.
Request
(
push_url
,
str2bytes
(
six
.
moves
.
urllib
.
parse
.
urlencode
(
{
'data'
:
data
,
{
'data
:bytes
'
:
data
,
'filename'
:
filename
,
'filename'
:
filename
,
'reference'
:
reference
,
'reference'
:
reference
,
'disable_cookie_login__'
:
1
,
'disable_cookie_login__'
:
1
,
})),
headers
=
{
})),
headers
=
{
'Authorization'
:
'Basic %s'
%
'Authorization'
:
'Basic %s'
%
base64
.
b64encode
(
b'ERP5TypeTestCase:'
)
base64
.
b64encode
(
b'ERP5TypeTestCase:'
)
.
decode
()
})
})
# disable_cookie_login__ is required to force zope to raise Unauthorized (401)
# disable_cookie_login__ is required to force zope to raise Unauthorized (401)
# then HTTPDigestAuthHandler can perform HTTP Authentication
# then HTTPDigestAuthHandler can perform HTTP Authentication
...
@@ -2172,11 +2173,10 @@ class Base_contributeMixin:
...
@@ -2172,11 +2173,10 @@ class Base_contributeMixin:
Test contributing an empty file and attaching it to context.
Test contributing an empty file and attaching it to context.
"""
"""
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
empty_file_upload
=
ZPublisher
.
HTTPRequest
.
FileUpload
(
FieldStorage
(
class
FileUpload
(
io
.
BytesIO
):
fp
=
io
.
BytesIO
(),
filename
=
"empty"
environ
=
dict
(
REQUEST_METHOD
=
'PUT'
),
headers
=
{}
headers
=
{
"content-disposition"
:
empty_file_upload
=
FileUpload
(
b""
)
"attachment; filename=empty;"
}))
contributed_document
=
person
.
Base_contribute
(
contributed_document
=
person
.
Base_contribute
(
portal_type
=
None
,
portal_type
=
None
,
...
@@ -2340,7 +2340,7 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
...
@@ -2340,7 +2340,7 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
))
self
.
assertIn
(
self
.
assertIn
(
(
'portal_status_message'
,
'PDF created successfully.'
),
(
'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
()
document
,
=
self
.
portal
.
document_module
.
contentValues
()
self
.
assertEqual
(
self
.
assertEqual
(
...
@@ -2358,7 +2358,7 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
...
@@ -2358,7 +2358,7 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
))
self
.
assertIn
(
self
.
assertIn
(
(
'portal_status_message'
,
'PDF updated successfully.'
),
(
'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
()
document
,
=
self
.
portal
.
document_module
.
contentValues
()
self
.
assertEqual
(
self
.
assertEqual
(
...
@@ -2382,10 +2382,10 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
...
@@ -2382,10 +2382,10 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
self
.
assertIn
(
self
.
assertIn
(
(
'portal_status_message'
,
(
'portal_status_message'
,
'You are not allowed to update the existing document which has the same coordinates.'
),
'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
(
self
.
assertIn
(
(
'portal_status_level'
,
'error'
),
(
'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
# document is not updated
self
.
assertEqual
(
document
.
getData
(),
b''
)
self
.
assertEqual
(
document
.
getData
(),
b''
)
...
@@ -2419,10 +2419,10 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
...
@@ -2419,10 +2419,10 @@ class TestBase_contributeWithSecurity(IngestionTestCase, Base_contributeMixin):
file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
))
file
=
self
.
makeFileUpload
(
'TEST-en-002.pdf'
))
self
.
assertIn
(
self
.
assertIn
(
(
'portal_status_message'
,
'You are not allowed to contribute document in that state.'
),
(
'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
(
self
.
assertIn
(
(
'portal_status_level'
,
'error'
),
(
'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
# when using the script directly it's an error
with
self
.
assertRaisesRegex
(
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