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
Carlos Ramos Carreño
erp5
Commits
7e775f3c
Commit
7e775f3c
authored
Feb 12, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testNotificationMessageModule: cleanups
parent
13c536d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
34 deletions
+11
-34
product/ERP5/tests/testNotificationMessageModule.py
product/ERP5/tests/testNotificationMessageModule.py
+11
-34
No files found.
product/ERP5/tests/testNotificationMessageModule.py
View file @
7e775f3c
...
...
@@ -27,11 +27,10 @@
#
##############################################################################
import
unittest
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
DummyMailHost
class
TestNotificationMessageModule
(
ERP5TypeTestCase
):
"""
...
...
@@ -40,39 +39,26 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
def
getBusinessTemplateList
(
self
):
return
(
'erp5_base'
,)
def
getTitle
(
self
):
return
'Notification Message Module'
def
getNotificationMessageModule
(
self
):
return
self
.
getPortal
().
notification_message_module
def
createUser
(
self
,
name
,
role_list
):
user_folder
=
self
.
getPortal
().
acl_users
user_folder
.
_doAddUser
(
name
,
'password'
,
role_list
,
[])
self
.
portal
.
acl_users
.
_doAddUser
(
name
,
self
.
newPassword
(),
role_list
,
[])
def
afterSetUp
(
self
):
self
.
createUser
(
'erp5user'
,
[
'Auditor'
,
'Author'
])
self
.
createUser
(
'manager'
,
[
'Manager'
])
portal
=
self
.
getPortal
()
if
'MailHost'
in
portal
.
objectIds
():
portal
.
manage_delObjects
([
'MailHost'
])
portal
.
_setObject
(
'MailHost'
,
DummyMailHost
(
'MailHost'
))
portal
.
email_from_address
=
'site@example.invalid'
self
.
portal
.
portal_caches
.
clearAllCache
()
self
.
tic
()
self
.
portal
.
email_from_address
=
'site@example.invalid'
self
.
loginByUserName
(
'erp5user'
)
def
beforeTearDown
(
self
):
self
.
abort
()
# clear modules if necessary
module_list
=
(
self
.
getNotificationMessageModule
()
,)
module_list
=
(
self
.
portal
.
notification_message_module
,)
for
module
in
module_list
:
module
.
manage_delObjects
(
list
(
module
.
objectIds
()))
self
.
tic
()
def
test_
01_get_document
(
self
):
module
=
self
.
getNotificationMessageModule
()
tool
=
self
.
getPortal
()
.
portal_notifications
def
test_
notification_tool_getDocumentValue
(
self
):
module
=
self
.
portal
.
notification_message_module
tool
=
self
.
portal
.
portal_notifications
self
.
loginByUserName
(
'manager'
)
#Test Document A in english
n_m_en
=
module
.
newContent
(
portal_type
=
'Notification Message'
,
...
...
@@ -108,11 +94,10 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
result
=
tool
.
getDocumentValue
(
reference
=
'A'
,
language
=
'fr'
)
self
.
assertEqual
(
result
.
getRelativeUrl
(),
n_m_fr_02
.
getRelativeUrl
())
def
test_substitution_content
(
self
):
"""Tests that content and subject have string.Template based substitutions
"""
module
=
self
.
getNotificationMessageModule
()
module
=
self
.
portal
.
notification_message_module
createZODBPythonScript
(
self
.
portal
,
'NotificationMessage_getDummySubstitionMapping'
,
'**kw'
,
...
...
@@ -130,11 +115,10 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
self
.
assertEqual
(
'Test b'
,
doc
.
asSubjectText
())
def
test_substitution_content_parameters
(
self
):
"""Tests that we can pass parameters to convert to the substitution method,
by using substitution_method_parameter_dict """
module
=
self
.
getNotificationMessageModule
()
module
=
self
.
portal
.
notification_message_module
createZODBPythonScript
(
self
.
portal
,
'NotificationMessage_getDummySubstitionMapping'
,
'**kw'
,
...
...
@@ -150,11 +134,10 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
substitution_method_parameter_dict
=
dict
(
a
=
'b'
))
self
.
assertEqual
(
'substitution text: b'
,
text
.
rstrip
())
def
test_substitution_content_and_convert
(
self
):
"""Tests that substitution also works with different target format.
"""
module
=
self
.
getNotificationMessageModule
()
module
=
self
.
portal
.
notification_message_module
createZODBPythonScript
(
self
.
portal
,
'NotificationMessage_getDummySubstitionMapping'
,
'**kw'
,
...
...
@@ -172,7 +155,7 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
"""Tests that 'safe' substitution is performed, unless safe_substitute is
explicitly passed to False.
"""
module
=
self
.
getNotificationMessageModule
()
module
=
self
.
portal
.
notification_message_module
createZODBPythonScript
(
self
.
portal
,
'NotificationMessage_getDummySubstitionMapping'
,
'**kw'
,
...
...
@@ -191,9 +174,3 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
self
.
assertRaises
(
KeyError
,
doc
.
convert
,
'txt'
,
safe_substitute
=
False
)
self
.
assertRaises
(
KeyError
,
doc
.
convert
,
'html'
,
safe_substitute
=
False
)
self
.
assertRaises
(
KeyError
,
doc
.
asSubjectText
,
safe_substitute
=
False
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestNotificationMessageModule
))
return
suite
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