Changeset 611
- Timestamp:
- 10/27/06 10:16:55
- Files:
-
- qPloneComments/tags/2.2.0-rc1/skins/qplonecomments/approve_comment_template.pt (modified) (2 diffs)
- qPloneComments/tags/2.2.0-rc1/tests/helperNotify.py (modified) (4 diffs)
- qPloneComments/tags/2.2.0-rc1/tests/sample (deleted)
- qPloneComments/tags/2.2.0-rc1/tests/testNotificationMailsSend.py (deleted)
- qPloneComments/tags/2.2.0-rc1/tests/testQPloneCommentsNotification.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/tags/2.2.0-rc1/skins/qplonecomments/approve_comment_template.pt
r610 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
r610 r611 15 15 PREFIX = os.path.abspath(os.path.dirname(__file__)) 16 16 17 def verifyMail(text, mail_type): 18 pass 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'] 19 21 20 22 def sample_file_path(file): … … 31 33 32 34 def writeToFile(f_path, text): 33 result_f = open(f_path, "a")35 result_f = open(f_path,'w') 34 36 result_f.write(text+'\n') 35 37 result_f.close() … … 40 42 result_f.close() 41 43 42 def testMailSend(self, state='approve'):43 result = getFileContent(output_file_path('mail.res'))44 sample = getFileContent(sample_file_path(state+'.mail'))45 # Check headers46 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 footer50 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 headers57 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 66 44 def _send_MH( self, mfrom, mto, messageText ): 67 writeToFile(output_file_path('mail.res'), messageText) 45 files = [f for f in os.listdir('./output') if f.startswith('mail')] 46 fn = files[-1]+ '1' 47 writeToFile(output_file_path(fn), messageText) 68 48 69 49 def _send_SMH(self, mfrom, mto, messageText, debug=False): 70 writeToFile(output_file_path('mail.res'), messageText) 50 files = [f for f in os.listdir('./output') if f.startswith('mail')] 51 fn = files[-1]+ '1' 52 writeToFile(output_file_path(fn), messageText) 71 53 72 54 def send_SMH(self, message, mto=None, mfrom=None, subject=None, encode=None): 73 writeToFile(output_file_path('mail.res'), message) 55 files = [f for f in os.listdir('./output') if f.startswith('mail')] 56 if files: 57 fn = files[-1]+ '1' 58 else: 59 fn = 'mail' 60 writeToFile(output_file_path(fn), message) 74 61 75 62 def prepareMailSendTest(): … … 80 67 SecureMailBase.send = send_SMH 81 68 SecureMailBase._send = _send_SMH 82 # clear 'mail.res' file 83 clearFile(output_file_path('mail.res')) 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'): 76 if f.startswith('mail'): 77 return True 78 return False 79 80 def cleanOutputDir(): 81 for f in os.listdir('./output'): 82 if f.startswith('mail'): os.remove('./output/%s'%f) qPloneComments/tags/2.2.0-rc1/tests/testQPloneCommentsNotification.py
r610 r611 16 16 PROPERTY_SHEET = "qPloneComments" 17 17 18 19 18 PloneTestCase.installProduct(PRODUCT) 20 19 PloneTestCase.setupPloneSite() … … 26 25 self.prefs._updateProperty('enable_approve_notification', swithA) 27 26 self.prefs._updateProperty('enable_published_notification', swithP) 28 29 27 30 28 def afterSetUp(self): … … 57 55 member = self.portal.portal_membership.getAuthenticatedMember() 58 56 member.setMemberProperties({'email':'creator@test.com'}) 59 57 60 58 # Add testing document to portal 61 59 my_doc = self.portal.invokeFactory('Document', id='my_doc') … … 71 69 prepareMailSendTest() 72 70 73 74 def testPublishedOFF(self): 71 def test_notificafion_disabled(self): 72 cleanOutputDir() 73 setProperties(self.prefs) 75 74 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 76 clearFile(output_file_path('mail.res')) 75 self.assert_(not testMailExistance(), 'Mail was sended when all notification was disabled') 76 77 def test_published_comment_notification(self): 78 cleanOutputDir() 79 setProperties(self.prefs, 'enable_published_notification') 80 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 81 self.assert_(testMailExistance(), 'Mail was not sended when enable_published_notification') 82 83 def test_approve_comment_notification(self): 84 cleanOutputDir() 85 setProperties(self.prefs, 'enable_approve_notification') 86 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 87 self.assert_(testMailExistance(), 'Mail was not sended when enable_approve_notification') 88 89 def test_reply_comment_user_notification(self): 90 cleanOutputDir() 91 setProperties(self.prefs, 'enable_reply_user_notification') 92 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 93 self.assert_(not testMailExistance(), 'Mail was sended for simple reply when enable_reply_user_notification') 94 77 95 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 96 reply.discussion_reply('A Reply for comment' ,'text of reply for comment') 97 reply_for_comment = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 98 self.assert_(testMailExistance(), 'Mail was not sended when enable_reply_user_notification') 78 99 79 # Set Published Notification OFF 80 self.setApprovePublished(swithA=0,swithP=0) 81 reply.discussion_publish_comment() 82 testNotMail(self) 100 def test_rejected_comment_notification(self): 101 cleanOutputDir() 102 setProperties(self.prefs, 'enable_rejected_user_notification', 'enable_moderation') 103 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 104 self.assert_(not testMailExistance(), 'Mail was sended when enable_rejected_user_notification was enabled') 83 105 84 def testPublishedON(self): 106 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 107 self.portal.REQUEST.set('ids', [reply.getId()]) 108 self.portal.prefs_recent_comments_delete() 109 self.assert_(testMailExistance(), 'Mail was not sended when enable_rejected_user_notification') 110 111 def test_approve_comment_user__notification(self): 112 cleanOutputDir() 113 setProperties(self.prefs, 'enable_approve_user_notification') 85 114 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') 93 94 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 115 self.assert_(testMailExistance(), 'Mail was not sended when enable_approve_user_notification') 148 116 149 117
