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
Ludovic Kiefer
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 @@
...
@@ -27,11 +27,10 @@
#
#
##############################################################################
##############################################################################
import
unittest
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
DummyMailHost
class
TestNotificationMessageModule
(
ERP5TypeTestCase
):
class
TestNotificationMessageModule
(
ERP5TypeTestCase
):
"""
"""
...
@@ -40,39 +39,26 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
...
@@ -40,39 +39,26 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
def
getBusinessTemplateList
(
self
):
def
getBusinessTemplateList
(
self
):
return
(
'erp5_base'
,)
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
):
def
createUser
(
self
,
name
,
role_list
):
user_folder
=
self
.
getPortal
().
acl_users
self
.
portal
.
acl_users
.
_doAddUser
(
name
,
self
.
newPassword
(),
role_list
,
[])
user_folder
.
_doAddUser
(
name
,
'password'
,
role_list
,
[])
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
self
.
createUser
(
'erp5user'
,
[
'Auditor'
,
'Author'
])
self
.
createUser
(
'erp5user'
,
[
'Auditor'
,
'Author'
])
self
.
createUser
(
'manager'
,
[
'Manager'
])
self
.
createUser
(
'manager'
,
[
'Manager'
])
portal
=
self
.
getPortal
()
self
.
portal
.
email_from_address
=
'site@example.invalid'
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
.
loginByUserName
(
'erp5user'
)
self
.
loginByUserName
(
'erp5user'
)
def
beforeTearDown
(
self
):
def
beforeTearDown
(
self
):
self
.
abort
()
self
.
abort
()
# clear modules if necessary
# clear modules if necessary
module_list
=
(
self
.
getNotificationMessageModule
()
,)
module_list
=
(
self
.
portal
.
notification_message_module
,)
for
module
in
module_list
:
for
module
in
module_list
:
module
.
manage_delObjects
(
list
(
module
.
objectIds
()))
module
.
manage_delObjects
(
list
(
module
.
objectIds
()))
self
.
tic
()
self
.
tic
()
def
test_
01_get_document
(
self
):
def
test_
notification_tool_getDocumentValue
(
self
):
module
=
self
.
getNotificationMessageModule
()
module
=
self
.
portal
.
notification_message_module
tool
=
self
.
getPortal
()
.
portal_notifications
tool
=
self
.
portal
.
portal_notifications
self
.
loginByUserName
(
'manager'
)
self
.
loginByUserName
(
'manager'
)
#Test Document A in english
#Test Document A in english
n_m_en
=
module
.
newContent
(
portal_type
=
'Notification Message'
,
n_m_en
=
module
.
newContent
(
portal_type
=
'Notification Message'
,
...
@@ -108,11 +94,10 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
...
@@ -108,11 +94,10 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
result
=
tool
.
getDocumentValue
(
reference
=
'A'
,
language
=
'fr'
)
result
=
tool
.
getDocumentValue
(
reference
=
'A'
,
language
=
'fr'
)
self
.
assertEqual
(
result
.
getRelativeUrl
(),
n_m_fr_02
.
getRelativeUrl
())
self
.
assertEqual
(
result
.
getRelativeUrl
(),
n_m_fr_02
.
getRelativeUrl
())
def
test_substitution_content
(
self
):
def
test_substitution_content
(
self
):
"""Tests that content and subject have string.Template based substitutions
"""Tests that content and subject have string.Template based substitutions
"""
"""
module
=
self
.
getNotificationMessageModule
()
module
=
self
.
portal
.
notification_message_module
createZODBPythonScript
(
self
.
portal
,
createZODBPythonScript
(
self
.
portal
,
'NotificationMessage_getDummySubstitionMapping'
,
'NotificationMessage_getDummySubstitionMapping'
,
'**kw'
,
'**kw'
,
...
@@ -130,11 +115,10 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
...
@@ -130,11 +115,10 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
self
.
assertEqual
(
'Test b'
,
doc
.
asSubjectText
())
self
.
assertEqual
(
'Test b'
,
doc
.
asSubjectText
())
def
test_substitution_content_parameters
(
self
):
def
test_substitution_content_parameters
(
self
):
"""Tests that we can pass parameters to convert to the substitution method,
"""Tests that we can pass parameters to convert to the substitution method,
by using substitution_method_parameter_dict """
by using substitution_method_parameter_dict """
module
=
self
.
getNotificationMessageModule
()
module
=
self
.
portal
.
notification_message_module
createZODBPythonScript
(
self
.
portal
,
createZODBPythonScript
(
self
.
portal
,
'NotificationMessage_getDummySubstitionMapping'
,
'NotificationMessage_getDummySubstitionMapping'
,
'**kw'
,
'**kw'
,
...
@@ -150,11 +134,10 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
...
@@ -150,11 +134,10 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
substitution_method_parameter_dict
=
dict
(
a
=
'b'
))
substitution_method_parameter_dict
=
dict
(
a
=
'b'
))
self
.
assertEqual
(
'substitution text: b'
,
text
.
rstrip
())
self
.
assertEqual
(
'substitution text: b'
,
text
.
rstrip
())
def
test_substitution_content_and_convert
(
self
):
def
test_substitution_content_and_convert
(
self
):
"""Tests that substitution also works with different target format.
"""Tests that substitution also works with different target format.
"""
"""
module
=
self
.
getNotificationMessageModule
()
module
=
self
.
portal
.
notification_message_module
createZODBPythonScript
(
self
.
portal
,
createZODBPythonScript
(
self
.
portal
,
'NotificationMessage_getDummySubstitionMapping'
,
'NotificationMessage_getDummySubstitionMapping'
,
'**kw'
,
'**kw'
,
...
@@ -172,7 +155,7 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
...
@@ -172,7 +155,7 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
"""Tests that 'safe' substitution is performed, unless safe_substitute is
"""Tests that 'safe' substitution is performed, unless safe_substitute is
explicitly passed to False.
explicitly passed to False.
"""
"""
module
=
self
.
getNotificationMessageModule
()
module
=
self
.
portal
.
notification_message_module
createZODBPythonScript
(
self
.
portal
,
createZODBPythonScript
(
self
.
portal
,
'NotificationMessage_getDummySubstitionMapping'
,
'NotificationMessage_getDummySubstitionMapping'
,
'**kw'
,
'**kw'
,
...
@@ -191,9 +174,3 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
...
@@ -191,9 +174,3 @@ class TestNotificationMessageModule(ERP5TypeTestCase):
self
.
assertRaises
(
KeyError
,
doc
.
convert
,
'txt'
,
safe_substitute
=
False
)
self
.
assertRaises
(
KeyError
,
doc
.
convert
,
'txt'
,
safe_substitute
=
False
)
self
.
assertRaises
(
KeyError
,
doc
.
convert
,
'html'
,
safe_substitute
=
False
)
self
.
assertRaises
(
KeyError
,
doc
.
convert
,
'html'
,
safe_substitute
=
False
)
self
.
assertRaises
(
KeyError
,
doc
.
asSubjectText
,
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