Changeset 1146
- Timestamp:
- 06/29/08 20:28:44
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/branches/plone-3.0/tests/testQPloneCommentsNotification.py
r1126 r1146 9 9 import re 10 10 from helperNotify import * 11 from email.Header import Header 11 12 from Products.qPloneComments.utils import getMsg 12 13 … … 54 55 self.login('dm') 55 56 # For prepare mail sending - enter an e-mail adress 57 self.portal.email_from_address = 'mail@plone.test' 56 58 self.prefs._updateProperty('email_discussion_manager', 'discussion.manager@test.com') 57 59 member = self.portal.portal_membership.getAuthenticatedMember() … … 59 61 60 62 # Add testing document to portal 61 my_doc = self.portal.invokeFactory('Document', id='my_doc' )63 my_doc = self.portal.invokeFactory('Document', id='my_doc', title='Doc') 62 64 self.my_doc = self.portal['my_doc'] 63 65 self.my_doc.edit(text_format='plain', text='hello world') … … 89 91 90 92 msg = getMsg(self.portal, 'reply_notify_template', args) 91 patt = re.compile('\\n \\n([^,]*)')93 patt = re.compile('\\n([^,]*?),\\n\\n') 92 94 m = patt.search(msg) 93 95 if m: … … 181 183 reply.deleteDiscussion() 182 184 mails = getMails() 183 self.assert_([1 for m in mails if re.search('^Subject:.*(not approved).*$', m, re.I|re.M)] \ 185 regexp = re.compile("Subject:\s*(.*?)$",re.M) 186 subject = str(Header('Your comment on "Doc" was not approved', 'utf-8')) 187 self.assert_([1 for m in mails if regexp.search(m).group(1) == subject] \ 184 188 ,'No notification for rejecting comment' % properties) 185 189 qPloneComments/branches/plone-3.0/tests/testQPloneCommentsNotificationRecipients.py
r1126 r1146 12 12 from common import * 13 13 from helperNotify import * 14 from email.Header import Header 14 15 from testQPloneCommentsModeration import USERS, COMMON_USERS_IDS, DM_USERS_IDS 15 16 … … 73 74 self.createMemberarea('owner') 74 75 75 ## Prepare mail sending - enter an e-mail adress, and allow all possible notifications 76 # Prepare mail sending - enter an e-mail adress, and allow all possible notifications 77 self.portal.email_from_address = 'mail@plone.test' 76 78 setProperties(self.prefs, 'enable_moderation', 'enable_approve_notification', 77 79 'enable_approve_user_notification','enable_reply_user_notification', 78 80 'enable_published_notification', 'enable_rejected_user_notification') 79 81 self.prefs._updateProperty('email_discussion_manager', 'discussion.manager@test.com') 82 self.prefs._updateProperty('email_subject_prefix', 'PREFIX') 80 83 81 # #Add testing document to portal84 # Add testing document to portal 82 85 self.login('owner') 83 86 self.portal.Members['owner'].invokeFactory('Document', id='my_doc', title="Test document") … … 85 88 self.my_doc.edit(text_format='plain', text='hello world') 86 89 87 # #Create talkback for document and Prepare REQUEST90 # Create talkback for document and Prepare REQUEST 88 91 self.discussion.getDiscussionFor(self.my_doc) 89 92 … … 93 96 messages = [m for m in mails if REXP_TO.search(m) and REXP_TO.search(m).group(1)==to] 94 97 self.assert_(len(messages) > 0, "No message sent to '%s' recipient" % to) 95 self.assert_([1 for m in messages if REXP_SUBJ.search(m) and REXP_SUBJ.search(m).group(1)==subj],\ 98 mangled = str(Header(subj, 'utf-8')) 99 self.assert_([1 for m in messages if REXP_SUBJ.search(m) and REXP_SUBJ.search(m).group(1)==mangled],\ 96 100 "There is no message for '%s' recipient with '%s' subject" % (to,subj)) 97 101 … … 103 107 mails = getMails() 104 108 self.assertEqual(len(mails), 1) 105 self.checkToANDSubj(mails, to="discussion.manager@test.com", subj="New comment awaits moderation") 109 self.checkToANDSubj(mails, to="discussion.manager@test.com", 110 subj="[PREFIX] New comment awaits moderation") 106 111 107 112 def test_PublishReply(self): … … 115 120 mails = getMails() 116 121 self.assertEqual(len(mails), 2) 117 self.checkToANDSubj(mails, to="owner@test.com", subj=" New comment added")118 self.checkToANDSubj(mails, to="replier1@test.com", subj= "Your comment on 'Test document' is now published")122 self.checkToANDSubj(mails, to="owner@test.com", subj="[PREFIX] New comment added") 123 self.checkToANDSubj(mails, to="replier1@test.com", subj='Your comment on "Test document" is now published') 119 124 120 125 def test_Publish2ndReply(self): … … 133 138 mails = getMails() 134 139 self.assertEqual(len(mails), 3) 135 self.checkToANDSubj(mails, to="owner@test.com", subj=" New comment added")136 self.checkToANDSubj(mails, to="replier1@test.com", subj= "Someone replied to your comment on 'Test document'")137 self.checkToANDSubj(mails, to="replier2@test.com", subj= "Your comment on 'Test document' is now published")140 self.checkToANDSubj(mails, to="owner@test.com", subj="[PREFIX] New comment added") 141 self.checkToANDSubj(mails, to="replier1@test.com", subj='Someone replied to your comment on "Test document"') 142 self.checkToANDSubj(mails, to="replier2@test.com", subj='Your comment on "Test document" is now published') 138 143 139 144 def test_DeleteReply(self): … … 147 152 mails = getMails() 148 153 self.assertEqual(len(mails), 1) 149 self.checkToANDSubj(mails, to="replier1@test.com", subj= "Your comment on 'Test document' was not approved.")154 self.checkToANDSubj(mails, to="replier1@test.com", subj='Your comment on "Test document" was not approved') 150 155 151 156
