Changeset 611 in products for qPloneComments/tags/2.2.0-rc1/tests/helperNotify.py
- Timestamp:
- Oct 27, 2006 3:16:55 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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'))
Note: See TracChangeset
for help on using the changeset viewer.