Changeset 612
- Timestamp:
- 10/27/06 10:39:36
- 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 (copied) (copied from qPloneComments/tags/2.2.0-rc1/tests/sample)
- qPloneComments/tags/2.2.0-rc1/tests/sample/approve.mail (copied) (copied from qPloneComments/tags/2.2.0-rc1/tests/sample/approve.mail)
- qPloneComments/tags/2.2.0-rc1/tests/sample/published.mail (copied) (copied from qPloneComments/tags/2.2.0-rc1/tests/sample/published.mail)
- qPloneComments/tags/2.2.0-rc1/tests/testNotificationMailsSend.py (copied) (copied from qPloneComments/tags/2.2.0-rc1/tests/testNotificationMailsSend.py)
- 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
r611 r612 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
r611 r612 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') if f.startswith('mail')] 46 fn = files[-1]+ '1' 47 writeToFile(output_file_path(fn), messageText) 67 writeToFile(output_file_path('mail.res'), messageText) 48 68 49 69 def _send_SMH(self, mfrom, mto, messageText, debug=False): 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) 70 writeToFile(output_file_path('mail.res'), messageText) 53 71 54 72 def send_SMH(self, message, mto=None, mfrom=None, subject=None, encode=None): 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) 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'): 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) 82 # clear 'mail.res' file 83 clearFile(output_file_path('mail.res')) qPloneComments/tags/2.2.0-rc1/tests/testQPloneCommentsNotification.py
r611 r612 16 16 PROPERTY_SHEET = "qPloneComments" 17 17 18 18 19 PloneTestCase.installProduct(PRODUCT) 19 20 PloneTestCase.setupPloneSite() … … 25 26 self.prefs._updateProperty('enable_approve_notification', swithA) 26 27 self.prefs._updateProperty('enable_published_notification', swithP) 28 27 29 28 30 def afterSetUp(self): … … 55 57 member = self.portal.portal_membership.getAuthenticatedMember() 56 58 member.setMemberProperties({'email':'creator@test.com'}) 57 59 58 60 # Add testing document to portal 59 61 my_doc = self.portal.invokeFactory('Document', id='my_doc') … … 69 71 prepareMailSendTest() 70 72 71 def test_notificafion_disabled(self): 72 cleanOutputDir() 73 setProperties(self.prefs) 73 74 def testPublishedOFF(self): 74 75 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 75 self.assert_(not testMailExistance(), 'Mail was sended when all notification was disabled') 76 clearFile(output_file_path('mail.res')) 77 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 76 78 77 def test_published_comment_notification(self): 78 cleanOutputDir() 79 setProperties(self.prefs, 'enable_published_notification') 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): 80 85 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') 86 clearFile(output_file_path('mail.res')) 87 reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 82 88 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') 89 # Set Published Notification ON 90 self.setApprovePublished(swithA=0,swithP=1) 91 reply.discussion_publish_comment() 92 testMailSend(self, state='published') 88 93 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 94 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') 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) 99 100 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')105 101 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') 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') 110 107 111 def test_approve_comment_user__notification(self): 112 cleanOutputDir() 113 setProperties(self.prefs, 'enable_approve_user_notification') 114 self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 115 self.assert_(testMailExistance(), 'Mail was not sended when enable_approve_user_notification') 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 116 148 117 149
