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
Paul Graydon
erp5
Commits
918f4740
Commit
918f4740
authored
Nov 15, 2018
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factorize code
parent
c57780ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
75 deletions
+44
-75
product/ERP5OOo/tests/testDeferredStyle.py
product/ERP5OOo/tests/testDeferredStyle.py
+44
-75
No files found.
product/ERP5OOo/tests/testDeferredStyle.py
View file @
918f4740
...
@@ -47,6 +47,8 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -47,6 +47,8 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
# address. Zope 2.12 only surrounds names with quotes if they really need
# address. Zope 2.12 only surrounds names with quotes if they really need
# quoting.
# quoting.
first_name
=
'Bob<Par'
first_name
=
'Bob<Par'
publication_section
=
"reporting"
classification
=
"collaborative"
def
getTitle
(
self
):
def
getTitle
(
self
):
return
'Test Deferred Style'
return
'Test Deferred Style'
...
@@ -142,21 +144,18 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -142,21 +144,18 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
else
:
else
:
self
.
fail
(
'Attachment not found in email
\
n
%s'
%
message_text
)
self
.
fail
(
'Attachment not found in email
\
n
%s'
%
message_text
)
def
test_report_stored_as_document
(
self
):
publication_section
=
"reporting"
def
_checkEmailLink
(
self
,
part
,
extension
=
None
,
content_type
=
None
):
classification
=
"collaborative"
content
=
part
.
get_payload
(
decode
=
True
)
system_preference
=
self
.
portal
.
portal_preferences
.
_getOb
(
'syspref'
,
None
)
self
.
assertTrue
(
"History%s"
%
extension
or
self
.
attachment_file_extension
in
content
)
system_preference
.
edit
(
preferred_deferred_report_stored_as_document
=
True
,
tree
=
html
.
fromstring
(
content
)
preferred_deferred_report_classification
=
classification
,
link
,
=
[
href
for
href
in
tree
.
xpath
(
'//a/@href'
)
if
href
]
preferred_deferred_report_publication_section
=
publication_section
,
relative_url
=
urlparse
.
urlparse
(
link
)
preferred_deferred_report_notification_message_reference
=
None
)
report
=
self
.
publish
(
relative_url
.
path
+
"?"
+
relative_url
.
query
,
'%s:%s'
%
(
self
.
username
,
self
.
password
))
self
.
loginAsUser
(
'bob'
)
self
.
assertEqual
(
httplib
.
OK
,
report
.
getStatus
())
self
.
portal
.
changeSkin
(
'Deferred'
)
self
.
assertEqual
(
report
.
getHeader
(
'content-type'
),
content_type
or
self
.
content_type
)
response
=
self
.
publish
(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
def
_checkDocument
(
self
):
%
(
self
.
portal
.
getId
(),
self
.
skin
),
'%s:%s'
%
(
self
.
username
,
self
.
password
))
self
.
tic
()
# A document has been created
document_list
=
self
.
portal
.
document_module
.
objectValues
()
document_list
=
self
.
portal
.
document_module
.
objectValues
()
self
.
assertEquals
(
len
(
document_list
),
1
)
self
.
assertEquals
(
len
(
document_list
),
1
)
document
=
document_list
[
0
].
getObject
()
document
=
document_list
[
0
].
getObject
()
...
@@ -165,10 +164,28 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -165,10 +164,28 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
self
.
assertEqual
(
'History'
,
document
.
getTitle
())
self
.
assertEqual
(
'History'
,
document
.
getTitle
())
self
.
assertEqual
(
None
,
document
.
getReference
())
self
.
assertEqual
(
None
,
document
.
getReference
())
self
.
assertEqual
(
"shared"
,
document
.
getValidationState
())
self
.
assertEqual
(
"shared"
,
document
.
getValidationState
())
self
.
assertEqual
(
publication_section
,
document
.
getPublicationSection
())
self
.
assertEqual
(
self
.
publication_section
,
document
.
getPublicationSection
())
self
.
assertEqual
(
classification
,
document
.
getClassification
())
self
.
assertEqual
(
self
.
classification
,
document
.
getClassification
())
self
.
assertEqual
(
self
.
portal_type
,
document
.
getPortalType
())
self
.
assertEqual
(
self
.
portal_type
,
document
.
getPortalType
())
def
_defineSystemPreference
(
self
,
notification_message_reference
=
None
):
system_preference
=
self
.
portal
.
portal_preferences
.
_getOb
(
'syspref'
,
None
)
system_preference
.
edit
(
preferred_deferred_report_stored_as_document
=
True
,
preferred_deferred_report_classification
=
self
.
classification
,
preferred_deferred_report_publication_section
=
self
.
publication_section
,
preferred_deferred_report_notification_message_reference
=
notification_message_reference
)
def
test_report_stored_as_document
(
self
):
self
.
_defineSystemPreference
()
self
.
loginAsUser
(
'bob'
)
self
.
portal
.
changeSkin
(
'Deferred'
)
response
=
self
.
publish
(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
%
(
self
.
portal
.
getId
(),
self
.
skin
),
'%s:%s'
%
(
self
.
username
,
self
.
password
))
self
.
tic
()
self
.
_checkDocument
()
last_message
=
self
.
portal
.
MailHost
.
_last_message
last_message
=
self
.
portal
.
MailHost
.
_last_message
self
.
assertNotEquals
((),
last_message
)
self
.
assertNotEquals
((),
last_message
)
mfrom
,
mto
,
message_text
=
last_message
mfrom
,
mto
,
message_text
=
last_message
...
@@ -177,17 +194,12 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -177,17 +194,12 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
for
part
in
mail_message
.
walk
():
for
part
in
mail_message
.
walk
():
content_type
=
part
.
get_content_type
()
content_type
=
part
.
get_content_type
()
if
content_type
==
"text/html"
:
if
content_type
==
"text/html"
:
# "History" is the title of Base_viewHistory form
self
.
_checkEmailLink
(
part
)
content
=
part
.
get_payload
()
self
.
assertTrue
(
"History%s"
%
self
.
attachment_file_extension
in
content
)
self
.
assertTrue
(
"erp5/document_module"
in
content
)
break
break
else
:
else
:
self
.
fail
(
'
Attachment
not found in email
\
n
%s'
%
message_text
)
self
.
fail
(
'
Link
not found in email
\
n
%s'
%
message_text
)
def
test_report_stored_as_document_with_notification_message
(
self
):
def
test_report_stored_as_document_with_notification_message
(
self
):
publication_section
=
"reporting"
classification
=
"collaborative"
createZODBPythonScript
(
self
.
portal
,
createZODBPythonScript
(
self
.
portal
,
'NotificationMessage_getSubstitutionMappingDictFromArgument'
,
'NotificationMessage_getSubstitutionMappingDictFromArgument'
,
'mapping_dict'
,
'mapping_dict'
,
...
@@ -203,29 +215,14 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -203,29 +215,14 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
agent
=
"person_module/pers"
)
agent
=
"person_module/pers"
)
notification_message
.
validate
()
notification_message
.
validate
()
self
.
tic
()
self
.
tic
()
system_preference
=
self
.
portal
.
portal_preferences
.
_getOb
(
'syspref'
,
None
)
self
.
_defineSystemPreference
(
"notification-deferred.report"
)
system_preference
.
edit
(
preferred_deferred_report_stored_as_document
=
True
,
preferred_deferred_report_classification
=
classification
,
preferred_deferred_report_publication_section
=
publication_section
,
preferred_deferred_report_notification_message_reference
=
"notification-deferred.report"
)
self
.
loginAsUser
(
'bob'
)
self
.
loginAsUser
(
'bob'
)
self
.
portal
.
changeSkin
(
'Deferred'
)
self
.
portal
.
changeSkin
(
'Deferred'
)
response
=
self
.
publish
(
response
=
self
.
publish
(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s'
%
(
self
.
portal
.
getId
(),
self
.
skin
),
'%s:%s'
%
(
self
.
username
,
self
.
password
))
%
(
self
.
portal
.
getId
(),
self
.
skin
),
'%s:%s'
%
(
self
.
username
,
self
.
password
))
self
.
tic
()
self
.
tic
()
# A document has been created
self
.
_checkDocument
()
document_list
=
self
.
portal
.
document_module
.
objectValues
()
self
.
assertEquals
(
len
(
document_list
),
1
)
document
=
document_list
[
0
].
getObject
()
expected_file_name
=
'History%s'
%
self
.
attachment_file_extension
self
.
assertEqual
(
expected_file_name
,
document
.
getFilename
())
self
.
assertEqual
(
'History'
,
document
.
getTitle
())
self
.
assertEqual
(
None
,
document
.
getReference
())
self
.
assertEqual
(
"shared"
,
document
.
getValidationState
())
self
.
assertEqual
(
publication_section
,
document
.
getPublicationSection
())
self
.
assertEqual
(
classification
,
document
.
getClassification
())
self
.
assertEqual
(
self
.
portal_type
,
document
.
getPortalType
())
last_message
=
self
.
portal
.
MailHost
.
_last_message
last_message
=
self
.
portal
.
MailHost
.
_last_message
self
.
assertNotEquals
((),
last_message
)
self
.
assertNotEquals
((),
last_message
)
...
@@ -235,27 +232,13 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -235,27 +232,13 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
for
part
in
mail_message
.
walk
():
for
part
in
mail_message
.
walk
():
content_type
=
part
.
get_content_type
()
content_type
=
part
.
get_content_type
()
if
content_type
==
"text/html"
:
if
content_type
==
"text/html"
:
# "History" is the title of Base_viewHistory form
self
.
_checkEmailLink
(
part
)
content
=
part
.
get_payload
(
decode
=
True
)
self
.
assertTrue
(
"History%s"
%
self
.
attachment_file_extension
in
content
)
tree
=
html
.
fromstring
(
content
)
link
,
=
[
href
for
href
in
tree
.
xpath
(
'//a/@href'
)
if
href
]
relative_url
=
urlparse
.
urlparse
(
link
)
report
=
self
.
publish
(
relative_url
.
path
+
"?"
+
relative_url
.
query
,
'%s:%s'
%
(
self
.
username
,
self
.
password
))
self
.
assertEqual
(
httplib
.
OK
,
report
.
getStatus
())
self
.
assertEqual
(
report
.
getHeader
(
'content-type'
),
self
.
content_type
)
break
break
else
:
else
:
self
.
fail
(
'
Attachment
not found in email
\
n
%s'
%
message_text
)
self
.
fail
(
'
Link
not found in email
\
n
%s'
%
message_text
)
def
test_pdf_report_stored_as_document
(
self
):
def
test_pdf_report_stored_as_document
(
self
):
publication_section
=
"reporting"
self
.
_defineSystemPreference
()
classification
=
"collaborative"
system_preference
=
self
.
portal
.
portal_preferences
.
_getOb
(
'syspref'
,
None
)
system_preference
.
edit
(
preferred_deferred_report_stored_as_document
=
True
,
preferred_deferred_report_classification
=
classification
,
preferred_deferred_report_publication_section
=
publication_section
,
preferred_deferred_report_notification_message_reference
=
None
)
self
.
loginAsUser
(
'bob'
)
self
.
loginAsUser
(
'bob'
)
self
.
portal
.
changeSkin
(
'Deferred'
)
self
.
portal
.
changeSkin
(
'Deferred'
)
response
=
self
.
publish
(
response
=
self
.
publish
(
...
@@ -263,17 +246,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -263,17 +246,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
%
(
self
.
portal
.
getId
(),
self
.
skin
),
'%s:%s'
%
(
self
.
username
,
self
.
password
))
%
(
self
.
portal
.
getId
(),
self
.
skin
),
'%s:%s'
%
(
self
.
username
,
self
.
password
))
self
.
tic
()
self
.
tic
()
# A document has been created
# A document has been created
document_list
=
self
.
portal
.
document_module
.
objectValues
()
self
.
_checkDocument
()
self
.
assertEquals
(
len
(
document_list
),
1
)
document
=
document_list
[
0
].
getObject
()
expected_file_name
=
'History%s'
%
self
.
attachment_file_extension
self
.
assertEqual
(
expected_file_name
,
document
.
getFilename
())
self
.
assertEqual
(
'History'
,
document
.
getTitle
())
self
.
assertEqual
(
None
,
document
.
getReference
())
self
.
assertEqual
(
"shared"
,
document
.
getValidationState
())
self
.
assertEqual
(
publication_section
,
document
.
getPublicationSection
())
self
.
assertEqual
(
classification
,
document
.
getClassification
())
self
.
assertEqual
(
self
.
portal_type
,
document
.
getPortalType
())
last_message
=
self
.
portal
.
MailHost
.
_last_message
last_message
=
self
.
portal
.
MailHost
.
_last_message
self
.
assertNotEquals
((),
last_message
)
self
.
assertNotEquals
((),
last_message
)
...
@@ -283,14 +256,10 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -283,14 +256,10 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
for
part
in
mail_message
.
walk
():
for
part
in
mail_message
.
walk
():
content_type
=
part
.
get_content_type
()
content_type
=
part
.
get_content_type
()
if
content_type
==
"text/html"
:
if
content_type
==
"text/html"
:
# "History" is the title of Base_viewHistory form
self
.
_checkEmailLink
(
part
,
".pdf"
,
"application/pdf"
)
content
=
part
.
get_payload
()
self
.
assertTrue
(
"History.pdf"
in
content
)
self
.
assertTrue
(
"erp5/document_module"
in
content
)
self
.
assertTrue
(
"format=3Dpdf"
in
content
)
break
break
else
:
else
:
self
.
fail
(
'
Attachment
not found in email
\
n
%s'
%
message_text
)
self
.
fail
(
'
Link
not found in email
\
n
%s'
%
message_text
)
def
test_normal_form
(
self
):
def
test_normal_form
(
self
):
self
.
loginAsUser
(
'bob'
)
self
.
loginAsUser
(
'bob'
)
...
...
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