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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
erp5
Commits
2f84834a
Commit
2f84834a
authored
Mar 14, 2018
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_interface_post: update test suite
parent
a11a81e2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
13 deletions
+66
-13
bt5/erp5_interface_post/TestTemplateItem/portal_components/test.erp5.testInterfacePost.py
...lateItem/portal_components/test.erp5.testInterfacePost.py
+66
-13
No files found.
bt5/erp5_interface_post/TestTemplateItem/portal_components/test.erp5.testInterfacePost.py
View file @
2f84834a
...
...
@@ -24,6 +24,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
import
email
import
time
from
Products.ERP5Type.tests.ERP5TypeLiveTestCase
import
ERP5TypeLiveTestCase
...
...
@@ -181,14 +182,19 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
def
stepCheckInternetMessagePostCreated
(
self
,
sequence
=
None
,
sequence_list
=
None
):
mail_message
=
sequence
[
'mail_message'
]
internet_message_post
,
=
mail_message
.
getAggregateValueList
(
internet_message_post
_list
=
mail_message
.
getAggregateValueList
(
portal_type
=
'Internet Message Post'
)
sequence
[
'internet_message_post'
]
=
internet_message_post
self
.
assertEqual
(
len
(
internet_message_post_list
),
len
(
self
.
recipient_list
))
sequence
[
'internet_message_post'
]
=
internet_message_post_list
[
0
]
sequence
[
'internet_message_post_list'
]
=
internet_message_post_list
self
.
assertEqual
(
0
,
len
(
mail_message
.
getAggregateDocumentTitleList
([])),
"Internet Message Post shouldn't be an attachment"
)
for
internet_message_post
in
internet_message_post_list
:
self
.
assertEqual
(
internet_message_post
.
getSimulationState
(),
'exported'
)
self
.
assertEqual
(
internet_message_post
.
getReference
(),
mail_message
.
getReference
()
...
...
@@ -205,8 +211,29 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
def
stepCheckLatestMessageFromMailHost
(
self
,
sequence
=
None
,
sequence_list
=
None
):
last_message
,
=
self
.
portal
.
MailHost
.
_message_list
self
.
assertNotEquals
((),
last_message
)
_
,
_
,
messageText
=
last_message
self
.
assertIn
(
messageText
,
sequence
[
'internet_message_post'
].
getData
())
_
,
_
,
message_text
=
last_message
self
.
assertIn
(
message_text
,
sequence
[
'internet_message_post'
].
getData
())
def
_getMailHostMessageForRecipient
(
self
,
recipient_email_address
):
message_list
=
self
.
portal
.
MailHost
.
_message_list
result_list
=
[]
for
message
in
message_list
:
_
,
to_list
,
_
=
message
for
recipient
in
to_list
:
if
recipient_email_address
in
recipient
:
result_list
.
append
(
message
)
return
result_list
def
stepCheckLatestMessageListFromMailHost
(
self
,
sequence
=
None
,
sequence_list
=
None
):
message_list
=
self
.
portal
.
MailHost
.
_message_list
self
.
assertEqual
(
len
(
message_list
),
len
(
self
.
recipient_list
))
for
post
in
sequence
[
'internet_message_post_list'
]:
post_recipient
=
email
.
message_from_string
(
post
.
getData
())[
'to'
]
message_list
=
self
.
_getMailHostMessageForRecipient
(
post_recipient
)
self
.
assertEqual
(
len
(
message_list
),
1
)
message
=
message_list
[
0
]
_
,
_
,
message_text
=
message
self
.
assertIn
(
message_text
,
post
.
getData
())
def
stepCheckMailMessagePreviewDisplaysLatestInternetMessagePostData
(
self
,
sequence
=
None
,
sequence_list
=
None
):
mail_message
=
sequence
[
'mail_message'
]
...
...
@@ -248,3 +275,29 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
test_sentMailMessageCreateOneInternetMessagePostForEachRecipient
(
self
):
"""
In case of multi recipients for emails, one mail message content is generated
and sent through the MailHost. As the purpose of Internet Message Post is to
track what goes out of ERP5, one Internet Message Post must be created for each
of these mail message contents.
"""
recipient_2
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
title
=
'recipient_2'
,
default_email_coordinate_text
=
'recipient_2@nexedi.com'
,
)
self
.
recipient_list
.
append
(
recipient_2
)
sequence_list
=
SequenceList
()
sequence_string
=
"""
stepCreateMailMessage
stepStartMailMessage
stepCheckMailMessage
stepTic
stepCheckInternetMessagePostCreated
stepCheckLatestMessageListFromMailHost
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
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