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
Hide 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
...
@@ -28,6 +28,7 @@ import time
from
Products.ERP5Type.tests.ERP5TypeLiveTestCase
import
ERP5TypeLiveTestCase
from
Products.ERP5Type.tests.ERP5TypeLiveTestCase
import
ERP5TypeLiveTestCase
from
Products.ERP5Type.tests.Sequence
import
SequenceList
from
Products.ERP5Type.tests.Sequence
import
SequenceList
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
,
removeZODBPythonScript
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
from
DateTime
import
DateTime
from
DateTime
import
DateTime
...
@@ -47,9 +48,15 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
...
@@ -47,9 +48,15 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
"""
"""
This is ran before anything, used to set the environment
This is ran before anything, used to set the environment
"""
"""
self
.
_setupLetterPostExportPythonScript
()
self
.
portal
.
MailHost
.
reset
()
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
# 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
# and creation_date of new documents, otherwise they won't be found by catalog
# during the fatest test sequences
# during the fatest test sequences
...
@@ -69,24 +76,14 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
...
@@ -69,24 +76,14 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
self
.
recipient_list
=
[
self
.
recipient
,]
self
.
recipient_list
=
[
self
.
recipient
,]
def
beforeTearDown
(
self
):
def
beforeTearDown
(
self
):
self
.
_removeLetterPostExportPythonScript
()
removeZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
def
_setupLetterPostExportPythonScript
(
self
):
"LetterPost_export"
skin_folder
=
self
.
portal
.
portal_skins
.
custom
)
script_id
=
"LetterPost_export"
script
=
getattr
(
skin_folder
,
script_id
,
None
)
for
module_id
in
(
'event_module'
,
'internet_message_post_module'
,
'letter_post_module'
):
if
script
is
None
:
module
=
self
.
portal
[
module_id
]
skin_folder
.
manage_addProduct
[
'PythonScripts'
]
\
module
.
manage_delObjects
(
module
.
objectIds
())
.
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'
)
def
_portal_catalog
(
self
,
**
kw
):
def
_portal_catalog
(
self
,
**
kw
):
result_list
=
self
.
portal
.
portal_catalog
(
**
kw
)
result_list
=
self
.
portal
.
portal_catalog
(
**
kw
)
...
@@ -202,6 +199,9 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
...
@@ -202,6 +199,9 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
internet_message_post
.
getData
())
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
):
def
stepCheckLatestMessageFromMailHost
(
self
,
sequence
=
None
,
sequence_list
=
None
):
last_message
,
=
self
.
portal
.
MailHost
.
_message_list
last_message
,
=
self
.
portal
.
MailHost
.
_message_list
self
.
assertNotEquals
((),
last_message
)
self
.
assertNotEquals
((),
last_message
)
...
@@ -216,37 +216,42 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
...
@@ -216,37 +216,42 @@ class TestInterfacePost(ERP5TypeLiveTestCase):
mail_message
.
MailMessage_viewPreview
.
my_text_content
.
render
(),
mail_message
.
MailMessage_viewPreview
.
my_text_content
.
render
(),
)
)
def
test_
onlyOneExportablePostIsExported
(
self
):
def
test_
emailSendingIsPilotedByInternetMessagePost
(
self
):
"""
"""
"""
"""
sequence_list
=
SequenceList
()
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
=
"""
sequence_string
=
"""
stepCreateLetterPost
stepCreateMailMessage
stepCreateLetterPost
stepStartMailMessage
stepCreateLetterPost
stepTic
stepAllowExportOfAllLetterPost
stepTic
stepTic
stepCheckOnlyOneLetterPostIsExported
stepCheckMailMessage
stepCheckInternetMessagePostCreated
stepCheckOnlyOneMessageHasBeenSentFromMailHost
stepCheckLatestMessageFromMailHost
"""
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
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
()
sequence_list
=
SequenceList
()
# With 3 Letter Posts, we can trigger a race condition where 2 letters
# With 3 Letter Posts, we can trigger a race condition where 2 letters
# disallow export of each other, thus nothing is exported.
# disallow export of each other, thus nothing is exported.
sequence_string
=
"""
sequence_string
=
"""
stepCreateMailMessage
stepCreateLetterPost
stepStartMailMessage
stepCreateLetterPost
stepCreateLetterPost
stepTic
stepTic
step
CheckMailMessage
step
AllowExportOfAllLetterPost
step
CheckInternetMessagePostCreated
step
Tic
stepCheck
LatestMessageFromMailHost
stepCheck
OnlyOneLetterPostIsExported
"""
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
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