Changeset 1633 in products for quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsNotification.py
- Timestamp:
- Feb 3, 2010 4:37:25 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonecomments/trunk/quintagroup/plonecomments/tests/testQPloneCommentsNotification.py
r1465 r1633 13 13 from config import * 14 14 15 from Products.CMFPlone.tests.utils import MockMailHost 16 17 REXP_TO = re.compile("To:\s*(.*?)$",re.M) 18 REXP_SUBJ = re.compile("Subject:\s*(.*?)$",re.M) 19 15 20 16 21 class TestNotification(FunctionalTestCase): … … 20 25 self.prefs._updateProperty('enable_published_notification', swithP) 21 26 27 def beforeTearDown(self): 28 self.portal.MailHost = self.portal._original_MailHost 29 22 30 def afterSetUp(self): 31 self.portal._original_MailHost = self.portal.MailHost 32 self.portal.MailHost = mailhost = MockMailHost('MailHost') 33 23 34 self.loginAsPortalOwner() 24 35 … … 64 75 self.request.form['body_text'] = "text of reply" 65 76 66 prepareMailSendTest()77 #prepareMailSendTest() 67 78 68 79 def test_bug_parent_reply(self): … … 93 104 94 105 def test_notificafion_disabled(self): 95 cleanOutputDir()106 self.portal.MailHost.reset() 96 107 setProperties(self.prefs) 97 108 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 98 self.failIf(testMailExistance( ), 'Mail was sended when all notification was disabled.')109 self.failIf(testMailExistance(self), 'Mail was sended when all notification was disabled.') 99 110 100 111 def test_published_comment_notification(self): 101 cleanOutputDir()112 self.portal.MailHost.reset() 102 113 setProperties(self.prefs, 'enable_published_notification') 103 114 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 104 self.failUnless(testMailExistance( ), 'Mail was not sended when enable_published_notification.')115 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_published_notification.') 105 116 106 117 def test_approve_comment_notification(self): 107 cleanOutputDir()118 self.portal.MailHost.reset() 108 119 setProperties(self.prefs, 'enable_approve_notification') 109 120 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 110 self.failUnless(testMailExistance( ), 'Mail was not sended when enable_approve_notification.')121 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_approve_notification.') 111 122 112 123 def test_reply_comment_user_notification(self): 113 cleanOutputDir()124 self.portal.MailHost.reset() 114 125 setProperties(self.prefs, 'enable_reply_user_notification') 115 126 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 116 self.failIf(testMailExistance( ), 'Mail was sended for simple reply when enable_reply_user_notification.')127 self.failIf(testMailExistance(self), 'Mail was sended for simple reply when enable_reply_user_notification.') 117 128 118 129 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 119 130 reply.discussion_reply('A Reply for comment' ,'text of reply for comment') 120 131 reply_for_comment = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 121 self.failUnless(testMailExistance( ), 'Mail was not sended when enable_reply_user_notification.')132 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_reply_user_notification.') 122 133 123 134 def test_rejected_comment_notification(self): 124 cleanOutputDir()135 self.portal.MailHost.reset() 125 136 setProperties(self.prefs, 'enable_rejected_user_notification', 'enable_moderation') 126 137 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 127 self.failIf(testMailExistance( ), 'Mail was sended when enable_rejected_user_notification was enabled.')138 self.failIf(testMailExistance(self), 'Mail was sended when enable_rejected_user_notification was enabled.') 128 139 129 140 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 130 141 self.portal.REQUEST.set('ids', [reply.getId()]) 131 142 self.portal.prefs_recent_comments_delete() 132 self.failUnless(testMailExistance( ), 'Mail was not sended when enable_rejected_user_notification.')143 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_rejected_user_notification.') 133 144 134 145 def test_approve_comment_user__notification(self): 135 cleanOutputDir()146 self.portal.MailHost.reset() 136 147 setProperties(self.prefs, 'enable_approve_user_notification') 137 148 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 138 self.failUnless(testMailExistance( ), 'Mail was not sended when enable_approve_user_notification.')149 self.failUnless(testMailExistance(self), 'Mail was not sended when enable_approve_user_notification.') 139 150 140 151 def test_bug_notification_on_single_reply_publish(self): … … 153 164 reply2 = self.discussion.getDiscussionFor(reply).getReplies()[0] 154 165 155 cleanOutputDir()166 self.portal.MailHost.reset() 156 167 reply2.discussion_publish_comment() 157 mails = getMails()158 self.failUnless([1 for m in mails if re.search('^Subject:.*(replied).*$', m, re.I|re.M)],168 mails = [str(m) for m in self.portal.MailHost.messages] 169 self.failUnless([1 for m in mails if REXP_SUBJ.search(m) and 'replied' in REXP_SUBJ.search(m).group(1)], 159 170 'No notification for reply.' % properties) 160 self.failUnless([1 for m in mails if re.search('^Subject:.*(added).*$', m, re.I|re.M)],171 self.failUnless([1 for m in mails if REXP_SUBJ.search(m) and 'added' in REXP_SUBJ.search(m).group(1)], 161 172 'No notification for adding comment.' % properties) 162 self.failUnless([1 for m in mails if re.search('^Subject:.*(published).*$', m, re.I|re.M)],173 self.failUnless([1 for m in mails if REXP_SUBJ.search(m) and 'published' in REXP_SUBJ.search(m).group(1)], 163 174 'No notification for publishing comment.' % properties) 164 175 … … 173 184 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 174 185 175 cleanOutputDir()186 self.portal.MailHost.reset() 176 187 reply.deleteDiscussion() 177 mails = getMails()188 mails = [str(m) for m in self.portal.MailHost.messages] 178 189 subject = str(Header('Your comment on Doc was not approved', 'utf-8')) 179 subjs = [message_from_string(m)['Subject'] for m in mails] 180 self.failUnless([1 for m in subjs if m == subject], 190 self.failUnless([1 for m in mails if REXP_SUBJ.search(m) and REXP_SUBJ.search(m).group(1)==subject], 181 191 'No notification for rejecting comment.' % properties) 182 192
Note: See TracChangeset
for help on using the changeset viewer.