Ignore:
Timestamp:
Oct 27, 2006 3:16:55 PM (18 years ago)
Author:
crchemist
Message:

New tests added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • qPloneComments/tags/2.2.0-rc1/tests/helperNotify.py

    r493 r611  
    1515PREFIX = os.path.abspath(os.path.dirname(__file__)) 
    1616 
    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'] 
     17def verifyMail(text,  mail_type): 
     18    pass 
    2119 
    2220def sample_file_path(file): 
     
    3331 
    3432def writeToFile(f_path, text): 
    35     result_f = open(f_path,'w') 
     33    result_f = open(f_path,"a") 
    3634    result_f.write(text+'\n') 
    3735    result_f.close() 
     
    4240    result_f.close() 
    4341 
     42def 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 
     53def 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 
     62def testNotMail(self): 
     63    result = getFileContent(output_file_path('mail.res')) 
     64    self.assert_(not result, "Mail was sended") 
     65 
    4466def _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) 
    4968 
    5069def _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) 
    5571 
    5672def 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) 
    6174 
    6275def prepareMailSendTest(): 
     
    6780        SecureMailBase.send = send_SMH 
    6881        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.