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
64d3875c
Commit
64d3875c
authored
Jan 19, 2018
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! erp5_interface_post: add test suite
parent
dc13fca7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
34 deletions
+39
-34
bt5/erp5_interface_post/TestTemplateItem/portal_components/test.erp5.testInterfacePost.py
...lateItem/portal_components/test.erp5.testInterfacePost.py
+39
-34
No files found.
bt5/erp5_interface_post/TestTemplateItem/portal_components/test.erp5.testInterfacePost.py
View file @
64d3875c
...
...
@@ -28,6 +28,7 @@ import time
from
Products.ERP5Type.tests.ERP5TypeLiveTestCase
import
ERP5TypeLiveTestCase
from
Products.ERP5Type.tests.Sequence
import
SequenceList
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
,
removeZODBPythonScript
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
from
DateTime
import
DateTime
...
...
@@ -47,9 +48,15 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
"""
This is ran before anything, used to set the environment
"""
self
.
_setupLetterPostExportPythonScript
()
self
.
portal
.
MailHost
.
reset
()
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
"LetterPost_export"
,
""
,
"if context.getSimulationState() == 'exportable':
\
n
context.export()"
,
)
# Make sure to have a difference of at least 1 second between test_launch_date
# and creation_date of new documents, otherwise they won't be found by catalog
# during the fatest test sequences
...
...
@@ -69,24 +76,14 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
self
.
recipient_list
=
[
self
.
recipient
,]
def
beforeTearDown
(
self
):
self
.
_removeLetterPostExportPythonScript
()
def
_setupLetterPostExportPythonScript
(
self
):
skin_folder
=
self
.
portal
.
portal_skins
.
custom
script_id
=
"LetterPost_export"
script
=
getattr
(
skin_folder
,
script_id
,
None
)
if
script
is
None
:
skin_folder
.
manage_addProduct
[
'PythonScripts'
]
\
.
manage_addPythonScript
(
id
=
script_id
)
skin_folder
[
script_id
].
write
(
"if context.getSimulationState() == 'exportable':
\
n
context.export()"
)
self
.
tic
()
def
_removeLetterPostExportPythonScript
(
self
):
skin_folder
=
self
.
portal
.
portal_skins
.
custom
script_id
=
"LetterPost_export"
script
=
getattr
(
skin_folder
,
script_id
,
None
)
if
script
is
not
None
:
skin_folder
.
manage_delObjects
(
'LetterPost_export'
)
removeZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
"LetterPost_export"
)
for
module_id
in
(
'event_module'
,
'internet_message_post_module'
,
'letter_post_module'
):
module
=
self
.
portal
[
module_id
]
module
.
manage_delObjects
(
module
.
objectIds
())
def
_portal_catalog
(
self
,
**
kw
):
result_list
=
self
.
portal
.
portal_catalog
(
**
kw
)
...
...
@@ -202,6 +199,9 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
internet_message_post
.
getData
())
)
def
stepCheckOnlyOneMessageHasBeenSentFromMailHost
(
self
,
sequence
=
None
,
sequence_list
=
None
):
self
.
assertEqual
(
1
,
self
.
portal
.
MailHost
.
getMessageList
())
def
stepCheckLatestMessageFromMailHost
(
self
,
sequence
=
None
,
sequence_list
=
None
):
last_message
,
=
self
.
portal
.
MailHost
.
_message_list
self
.
assertNotEquals
((),
last_message
)
...
...
@@ -216,37 +216,42 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
mail_message
.
MailMessage_viewPreview
.
my_text_content
.
render
(),
)
def
test_
onlyOneExportablePostIsExported
(
self
):
def
test_
emailSendingIsPilotedByInternetMessagePost
(
self
):
"""
"""
sequence_list
=
SequenceList
()
# With 3 Letter Posts, we can trigger a race condition where 2 letters
# disallow export of each other, thus nothing is exported.
sequence_string
=
"""
stepCreateLetterPost
stepCreateLetterPost
stepCreateLetterPost
stepTic
stepAllowExportOfAllLetterPost
stepCreateMailMessage
stepStartMailMessage
stepTic
stepCheckOnlyOneLetterPostIsExported
stepCheckMailMessage
stepCheckInternetMessagePostCreated
stepCheckOnlyOneMessageHasBeenSentFromMailHost
stepCheckLatestMessageFromMailHost
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
test_
emailSendingIsPilotedByInternetMessagePost
(
self
):
def
test_
onlyOneExportablePostIsExported
(
self
):
"""
interface_post_workflow defines "exportable" and "exported" states, as for some portal types
we may stack all new objects, and regularly export them all at once. Ie, for letters, we can
gather them all in a unique PDF and send it to a printer.
As a user may send an Event, then rework on it, and re-send it, it will create 2 Posts for
the same Event. In that case, we want only one of these posts to be exported, and the others
become "unexportable".
"""
sequence_list
=
SequenceList
()
# With 3 Letter Posts, we can trigger a race condition where 2 letters
# disallow export of each other, thus nothing is exported.
sequence_string
=
"""
stepCreateMailMessage
stepStartMailMessage
stepCreateLetterPost
stepCreateLetterPost
stepCreateLetterPost
stepTic
step
CheckMailMessage
step
CheckInternetMessagePostCreated
stepCheck
LatestMessageFromMailHost
step
AllowExportOfAllLetterPost
step
Tic
stepCheck
OnlyOneLetterPostIsExported
"""
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