Changeset 611 in products
- Timestamp:
- Oct 27, 2006 3:16:55 PM (18 years ago)
- Location:
- qPloneComments/tags/2.2.0-rc1
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
qPloneComments/tags/2.2.0-rc1/skins/qplonecomments/approve_comment_template.pt
r571 r611 1 <div i18n:domain="plonecomments" 1 <div i18n:domain="plonecomments" 2 2 tal:omit-tag="" 3 3 tal:define="charset here/portal_properties/site_properties/default_charset|string:utf-8; … … 15 15 16 16 -- 17 <tal:signature i18n:translate="signature"> 18 <tal:organization_name condition="organization_name" 19 replace="string:$organization_name" 17 <tal:signature i18n:translate="signature"> 18 <tal:organization_name condition="organization_name" 19 replace="string:$organization_name" 20 20 i18n:name="organization_name"/> 21 Support Team21 Support Team 22 22 </tal:signature> 23 23 </div> -
qPloneComments/tags/2.2.0-rc1/tests/helperNotify.py
r493 r611 15 15 PREFIX = os.path.abspath(os.path.dirname(__file__)) 16 16 17 ALL_PROPS = ['enable_approve_user_notification', 'enable_reply_user_notification', 18 'enable_rejected_user_notification','enable_moderation', 19 'require_email', 'enable_anonymous_commenting', 20 'enable_published_notification', 'enable_approve_notification'] 17 def verifyMail(text, mail_type): 18 pass 21 19 22 20 def sample_file_path(file): … … 33 31 34 32 def writeToFile(f_path, text): 35 result_f = open(f_path, 'w')33 result_f = open(f_path,"a") 36 34 result_f.write(text+'\n') 37 35 result_f.close() … … 42 40 result_f.close() 43 41 42 def testMailSend(self, state='approve'): 43 result = getFileContent(output_file_path('mail.res')) 44 sample = getFileContent(sample_file_path(state+'.mail')) 45 # Check headers 46 sample_headers = sample.split('\n')[:2] 47 for header in sample_headers: 48 self.assert_(header in result, "State:'%s'. Header '%s' not present in sended mail" % (state, header) ) 49 # Check footer 50 sample_footer = sample.split('\n')[-2:-1] 51 self.assert_(sample_footer[0] in result, "State:'%s'. Footer '%s' not present in sended mail" % (state, sample_footer[0]) ) 52 53 def testNotMailSend(self, state='approve'): 54 result = getFileContent(output_file_path('mail.res')) 55 sample = getFileContent(sample_file_path(state+'.mail')) 56 # Check headers 57 sample_headers = sample.split('\n')[:2] 58 del sample_headers[1] 59 for header in sample_headers: 60 self.assert_(not header in result, "State:'%s'. Header '%s' present in sended mail" % (state, header) ) 61 62 def testNotMail(self): 63 result = getFileContent(output_file_path('mail.res')) 64 self.assert_(not result, "Mail was sended") 65 44 66 def _send_MH( self, mfrom, mto, messageText ): 45 files = [f for f in os.listdir(output_file_path("")) if f.startswith('mail')] 46 files.sort() 47 fn = files and (files[-1]+ '1') or 'mail' 48 writeToFile(output_file_path(fn), messageText) 67 writeToFile(output_file_path('mail.res'), messageText) 49 68 50 69 def _send_SMH(self, mfrom, mto, messageText, debug=False): 51 files = [f for f in os.listdir(output_file_path("")) if f.startswith('mail')] 52 files.sort() 53 fn = files and (files[-1]+ '1') or 'mail' 54 writeToFile(output_file_path(fn), messageText) 70 writeToFile(output_file_path('mail.res'), messageText) 55 71 56 72 def send_SMH(self, message, mto=None, mfrom=None, subject=None, encode=None): 57 files = [f for f in os.listdir(output_file_path("")) if f.startswith('mail')] 58 files.sort() 59 fn = files and (files[-1]+ '1') or 'mail' 60 writeToFile(output_file_path(fn), message) 73 writeToFile(output_file_path('mail.res'), message) 61 74 62 75 def prepareMailSendTest(): … … 67 80 SecureMailBase.send = send_SMH 68 81 SecureMailBase._send = _send_SMH 69 70 def setProperties(prop_sheet, *props): 71 for p in ALL_PROPS: 72 prop_sheet._updateProperty(p, p in props) 73 74 def testMailExistance(): 75 for f in os.listdir(output_file_path("")): 76 if f.startswith('mail'): 77 return True 78 return False 79 80 def getMails(): 81 return [file(output_file_path(f),'r').read() for f in os.listdir(output_file_path("")) if f.startswith('mail')] 82 83 84 def cleanOutputDir(): 85 for f in os.listdir(output_file_path("")): 86 if f.startswith('mail'): os.remove(output_file_path(f)) 82 # clear 'mail.res' file 83 clearFile(output_file_path('mail.res')) -
qPloneComments/tags/2.2.0-rc1/tests/testQPloneCommentsNotification.py
r493 r611 1 # 1 # 2 2 # Test configuration form working 3 3 # 4 4 5 5 import os, sys, string 6 7 6 if __name__ == '__main__': 8 7 execfile(os.path.join(sys.path[0], 'framework.py')) … … 12 11 from Products.CMFCore.CMFCorePermissions import ManagePortal, ReplyToItem 13 12 from Products.MailHost.MailHost import MailBase 14 15 import re16 17 from Products.qPloneComments.utils import getMsg18 13 from helperNotify import * 19 14 20 15 PRODUCT = 'qPloneComments' 21 16 PROPERTY_SHEET = "qPloneComments" 17 22 18 23 19 PloneTestCase.installProduct(PRODUCT) … … 30 26 self.prefs._updateProperty('enable_approve_notification', swithA) 31 27 self.prefs._updateProperty('enable_published_notification', swithP) 28 32 29 33 30 def afterSetUp(self): … … 60 57 member = self.portal.portal_membership.getAuthenticatedMember() 61 58 member.setMemberProperties({'email':'creator@test.com'}) 62 59 63 60 # Add testing document to portal 64 61 my_doc = self.portal.invokeFactory('Document', id='my_doc') … … 74 71 prepareMailSendTest() 75 72 76 def test_bug_parent_reply(self):77 setProperties(self.prefs, 'enable_reply_user_notification')73 74 def testPublishedOFF(self): 78 75 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 79 parent_reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 80 parent_reply.discussion_reply('reply', 'text') 81 82 def test_bug_mistakable_names(self): 83 setProperties(self.prefs, 'enable_reply_user_notification') 84 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 85 parent_reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 86 87 args={'mto': 'user_email@gmail.com', 88 'mfrom': 'admin_email@gmail.com', 89 'obj': parent_reply, 90 'organization_name': 'org_name', 91 'name': parent_reply.getOwnerTuple()[1]} 92 93 msg = getMsg(self.portal, 'reply_notify_template', args) 94 patt = re.compile('\\n\\n([^,]*)') 95 m = patt.search(msg) 96 if m: 97 name = m.group(1) 98 self.assertEqual(parent_reply.getOwnerTuple()[1], name) 99 else: 100 raise "No name" 101 102 def test_notificafion_disabled(self): 103 cleanOutputDir() 104 setProperties(self.prefs) 105 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 106 self.assert_(not testMailExistance(), 'Mail was sended when all notification was disabled') 107 108 def test_published_comment_notification(self): 109 cleanOutputDir() 110 setProperties(self.prefs, 'enable_published_notification') 111 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 112 self.assert_(testMailExistance(), 'Mail was not sended when enable_published_notification') 113 114 def test_approve_comment_notification(self): 115 cleanOutputDir() 116 setProperties(self.prefs, 'enable_approve_notification') 117 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 118 self.assert_(testMailExistance(), 'Mail was not sended when enable_approve_notification') 119 120 def test_reply_comment_user_notification(self): 121 cleanOutputDir() 122 setProperties(self.prefs, 'enable_reply_user_notification') 123 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 124 self.assert_(not testMailExistance(), 'Mail was sended for simple reply when enable_reply_user_notification') 125 126 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 127 reply.discussion_reply('A Reply for comment' ,'text of reply for comment') 128 reply_for_comment = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 129 self.assert_(testMailExistance(), 'Mail was not sended when enable_reply_user_notification') 130 131 def test_rejected_comment_notification(self): 132 cleanOutputDir() 133 setProperties(self.prefs, 'enable_rejected_user_notification', 'enable_moderation') 134 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 135 self.assert_(not testMailExistance(), 'Mail was sended when enable_rejected_user_notification was enabled') 136 137 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 138 self.portal.REQUEST.set('ids', [reply.getId()]) 139 self.portal.prefs_recent_comments_delete() 140 self.assert_(testMailExistance(), 'Mail was not sended when enable_rejected_user_notification') 141 142 def test_approve_comment_user__notification(self): 143 cleanOutputDir() 144 setProperties(self.prefs, 'enable_approve_user_notification') 145 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 146 self.assert_(testMailExistance(), 'Mail was not sended when enable_approve_user_notification') 147 148 def test_bug_notification_on_single_reply_publish(self): 149 """ Bug: no notification sent on publishing single comment. 150 Must be 3 mails: for replier about replying on his commen; 151 for replier about publishig his comment; 152 for document creator about adding new comment. 153 """ 154 properties = ['enable_approve_user_notification', 'enable_reply_user_notification', 155 'enable_published_notification'] 156 setProperties(self.prefs, *properties) 157 #setProperties(self.prefs, 'enable_published_notification', ) 158 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 159 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 160 reply.discussion_reply('A Reply for reply for my_doc' ,'text of reply on reply for my_doc') 161 reply2 = self.discussion.getDiscussionFor(reply).getReplies()[0] 162 163 cleanOutputDir() 164 reply2.discussion_publish_comment() 165 mails = getMails() 166 self.assert_([1 for m in mails if re.search('^Subject:.*(replied).*$', m, re.I|re.M)] \ 167 ,'No notification for reply' % properties) 168 self.assert_([1 for m in mails if re.search('^Subject:.*(added).*$', m, re.I|re.M)] \ 169 , 'No notification for adding comment' % properties) 170 self.assert_([1 for m in mails if re.search('^Subject:.*(published).*$', m, re.I|re.M)] \ 171 , 'No notification for publishing comment' % properties) 172 173 def test_bug_notification_on_single_reply_delete(self): 174 """ Bug: no notification sent on deleting single comment. 175 Mail about rejecing comment should be sent to comentator. 176 """ 177 properties = ['enable_rejected_user_notification',] 178 setProperties(self.prefs, *properties) 179 #setProperties(self.prefs, 'enable_published_notification', ) 180 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 76 clearFile(output_file_path('mail.res')) 181 77 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 182 78 183 cleanOutputDir() 184 reply.deleteDiscussion() 185 mails = getMails() 186 self.assert_([1 for m in mails if re.search('^Subject:.*(not approved).*$', m, re.I|re.M)] \ 187 ,'No notification for rejecting comment' % properties) 79 # Set Published Notification OFF 80 self.setApprovePublished(swithA=0,swithP=0) 81 reply.discussion_publish_comment() 82 testNotMail(self) 83 84 def testPublishedON(self): 85 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 86 clearFile(output_file_path('mail.res')) 87 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 88 89 # Set Published Notification ON 90 self.setApprovePublished(swithA=0,swithP=1) 91 reply.discussion_publish_comment() 92 testMailSend(self, state='published') 188 93 189 94 190 #def test_ 95 def testApproveOFF(self): 96 # Set Approve Notification OFF 97 self.setApprovePublished(swithA=0,swithP=0) 98 self.my_doc.discussion_reply('Reply 1', 'text of reply') 99 testNotMail(self) 100 101 102 def testApproveON(self): 103 # Set Approve Notification ON 104 self.setApprovePublished(swithA=1,swithP=0) 105 self.my_doc.discussion_reply('Reply 1', 'text of reply') 106 testMailSend(self, state='approve') 107 108 109 def testOFFModerationApprovePublished(self): 110 self.prefs._updateProperty('enable_moderation', 0) 111 112 # Test Enable Approve Notification & Enable Published Notification 113 self.setApprovePublished(swithA=1, swithP=1) 114 self.my_doc.discussion_reply('Reply 1', 'text of reply') 115 testMailSend(self, state='approve') 116 testMailSend(self, state='published') 117 118 119 def testOFFModerationApprove(self): 120 self.prefs._updateProperty('enable_moderation', 0) 121 122 # Test Enable Approve Notification & Disable Published Notification 123 self.setApprovePublished(swithA=1,swithP=0) 124 self.my_doc.discussion_reply('Reply 1', 'text of reply') 125 testMailSend(self, state='approve') 126 testNotMailSend(self, state='published') 127 128 129 def testOFFModerationPublished(self): 130 self.prefs._updateProperty('enable_moderation', 0) 131 132 # Test Enable Published Notification & Disable Approve Notification 133 self.setApprovePublished(swithA=0,swithP=1) 134 self.my_doc.discussion_reply('Reply 1', 'text of reply') 135 testNotMailSend(self, state='approve') 136 testMailSend(self, state='published') 137 138 139 def testOFFModeration(self): 140 self.prefs._updateProperty('enable_moderation', 0) 141 142 # Test Disable Published Notification & Disable Approve Notification 143 self.setApprovePublished(swithA=0,swithP=0) 144 self.my_doc.discussion_reply('Reply 1', 'text of reply') 145 testNotMailSend(self, state='approve') 146 testNotMailSend(self, state='published') 147 148 191 149 192 150 TESTS = [TestNotification]
Note: See TracChangeset
for help on using the changeset viewer.