Commit 3ff9c0e6 authored by Yusei Tahara's avatar Yusei Tahara

Added two tests for checking text format.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21448 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0e0f1ce3
...@@ -492,6 +492,90 @@ class TestNotificationTool(ERP5TypeTestCase): ...@@ -492,6 +492,90 @@ class TestNotificationTool(ERP5TypeTestCase):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def stepCheckNotificationPlainTextFormat(self, sequence=None,
sequence_list=None, **kw):
"""
Check that if notification format is plain text.
"""
message = """\
> Hello, will you go to the park on sunday?
Yes, I will go.
"""
self.portal.portal_notifications.sendMessage(
recipient='userA', subject='Subject',
message_text_format='text/plain', message=message)
last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message)
mfrom, mto, messageText = last_message
self.assertEquals('site@example.invalid', mfrom)
self.assertEquals(['userA@example.invalid'], mto)
# Check Message
mail_dict = decode_email(messageText)
self.assertEquals(mail_dict['headers']['subject'], 'Subject')
self.assertEquals(mail_dict['body'], message)
self.assertSameSet([], mail_dict['attachment_list'])
def test_11_TextMessage(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
message = 'Test message format'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList()
sequence_string = '\
AddUserA \
Tic \
CheckNotificationPlainTextFormat \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def stepCheckNotificationHtmlFormat(self, sequence=None,
sequence_list=None, **kw):
"""
Check that if notification format is html.
"""
message = """\
<a href="http://www.erp5.com/">Click Here!!</a>
"""
self.portal.portal_notifications.sendMessage(
recipient='userA', subject='Subject',
message_text_format='text/html', message=message)
last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message)
mfrom, mto, messageText = last_message
self.assertEquals('site@example.invalid', mfrom)
self.assertEquals(['userA@example.invalid'], mto)
# Check Message
mail_dict = decode_email(messageText)
self.assertEquals(mail_dict['headers']['subject'], 'Subject')
#
# Without CRM, it does not support HTML mail.
#
self.assertEquals(mail_dict['body'], 'Click Here!!\n')
self.assertSameSet([], mail_dict['attachment_list'])
def test_12_HtmlMessage(self, quiet=quiet, run=run_all_test):
if not run: return
if not quiet:
message = 'Test message format'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList()
sequence_string = '\
AddUserA \
Tic \
CheckNotificationHtmlFormat \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
class TestNotificationToolWithCRM(TestNotificationTool): class TestNotificationToolWithCRM(TestNotificationTool):
"""Make sure that notification tool works with crm""" """Make sure that notification tool works with crm"""
...@@ -499,6 +583,33 @@ class TestNotificationToolWithCRM(TestNotificationTool): ...@@ -499,6 +583,33 @@ class TestNotificationToolWithCRM(TestNotificationTool):
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
return ('erp5_base', 'erp5_crm') return ('erp5_base', 'erp5_crm')
def stepCheckNotificationHtmlFormat(self, sequence=None,
sequence_list=None, **kw):
"""
Check that if notification format is html.
"""
message = """\
<a href="http://www.erp5.com/">Click Here!!</a>
"""
self.portal.portal_notifications.sendMessage(
recipient='userA', subject='Subject',
message_text_format='text/html', message=message)
last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message)
mfrom, mto, messageText = last_message
self.assertEquals('site@example.invalid', mfrom)
self.assertEquals(['userA@example.invalid'], mto)
# Check Message
mail_dict = decode_email(messageText)
self.assertEquals(mail_dict['headers']['subject'], 'Subject')
#
# With CRM, it support HTML mail.
#
self.assertEquals(mail_dict['body'], message)
self.assertSameSet([], mail_dict['attachment_list'])
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment