Changeset 1146

Show
Ignore:
Timestamp:
06/29/08 20:28:44
Author:
deo
Message:

The subject header line must be encoded with the format from the email.Header.Header class. Made sure to set a fake value for email_from_address, as SMH checks for something with a valid format. Fixed the tests to take into account the email_subject_prefix value.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneComments/branches/plone-3.0/tests/testQPloneCommentsNotification.py

    r1126 r1146  
    99import re 
    1010from helperNotify import * 
     11from email.Header import Header 
    1112from Products.qPloneComments.utils import getMsg 
    1213 
     
    5455        self.login('dm') 
    5556        # For prepare mail sending - enter an e-mail adress 
     57        self.portal.email_from_address = 'mail@plone.test' 
    5658        self.prefs._updateProperty('email_discussion_manager', 'discussion.manager@test.com') 
    5759        member = self.portal.portal_membership.getAuthenticatedMember() 
     
    5961 
    6062        # Add testing document to portal 
    61         my_doc = self.portal.invokeFactory('Document', id='my_doc'
     63        my_doc = self.portal.invokeFactory('Document', id='my_doc', title='Doc'
    6264        self.my_doc = self.portal['my_doc'] 
    6365        self.my_doc.edit(text_format='plain', text='hello world') 
     
    8991 
    9092        msg = getMsg(self.portal, 'reply_notify_template', args) 
    91         patt = re.compile('\\n\\n([^,]*)') 
     93        patt = re.compile('\\n([^,]*?),\\n\\n') 
    9294        m = patt.search(msg) 
    9395        if m: 
     
    181183        reply.deleteDiscussion() 
    182184        mails = getMails() 
    183         self.assert_([1 for m in mails if re.search('^Subject:.*(not approved).*$', m, re.I|re.M)] \ 
     185        regexp = re.compile("Subject:\s*(.*?)$",re.M) 
     186        subject = str(Header('Your comment on "Doc" was not approved', 'utf-8')) 
     187        self.assert_([1 for m in mails if regexp.search(m).group(1) == subject] \ 
    184188                     ,'No notification for rejecting comment' % properties) 
    185189 
  • qPloneComments/branches/plone-3.0/tests/testQPloneCommentsNotificationRecipients.py

    r1126 r1146  
    1212from common import * 
    1313from helperNotify import * 
     14from email.Header import Header 
    1415from testQPloneCommentsModeration import USERS, COMMON_USERS_IDS, DM_USERS_IDS 
    1516 
     
    7374        self.createMemberarea('owner') 
    7475 
    75         ## Prepare mail sending - enter an e-mail adress, and allow all possible notifications 
     76        # Prepare mail sending - enter an e-mail adress, and allow all possible notifications 
     77        self.portal.email_from_address = 'mail@plone.test' 
    7678        setProperties(self.prefs, 'enable_moderation', 'enable_approve_notification', 
    7779                                  'enable_approve_user_notification','enable_reply_user_notification', 
    7880                                  'enable_published_notification', 'enable_rejected_user_notification') 
    7981        self.prefs._updateProperty('email_discussion_manager', 'discussion.manager@test.com') 
     82        self.prefs._updateProperty('email_subject_prefix', 'PREFIX') 
    8083 
    81         ## Add testing document to portal 
     84        # Add testing document to portal 
    8285        self.login('owner') 
    8386        self.portal.Members['owner'].invokeFactory('Document', id='my_doc', title="Test document") 
     
    8588        self.my_doc.edit(text_format='plain', text='hello world') 
    8689 
    87         ## Create talkback for document and Prepare REQUEST 
     90        # Create talkback for document and Prepare REQUEST 
    8891        self.discussion.getDiscussionFor(self.my_doc) 
    8992 
     
    9396        messages = [m for m in mails if REXP_TO.search(m) and REXP_TO.search(m).group(1)==to] 
    9497        self.assert_(len(messages) > 0, "No message sent to '%s' recipient" % to) 
    95         self.assert_([1 for m in messages if REXP_SUBJ.search(m) and REXP_SUBJ.search(m).group(1)==subj],\ 
     98        mangled = str(Header(subj, 'utf-8')) 
     99        self.assert_([1 for m in messages if REXP_SUBJ.search(m) and REXP_SUBJ.search(m).group(1)==mangled],\ 
    96100                     "There is no message for '%s' recipient with '%s' subject" % (to,subj)) 
    97101 
     
    103107        mails = getMails() 
    104108        self.assertEqual(len(mails), 1) 
    105         self.checkToANDSubj(mails, to="discussion.manager@test.com", subj="New comment awaits moderation") 
     109        self.checkToANDSubj(mails, to="discussion.manager@test.com", 
     110                            subj="[PREFIX] New comment awaits moderation") 
    106111 
    107112    def test_PublishReply(self): 
     
    115120        mails = getMails() 
    116121        self.assertEqual(len(mails), 2) 
    117         self.checkToANDSubj(mails, to="owner@test.com", subj="New comment added") 
    118         self.checkToANDSubj(mails, to="replier1@test.com", subj="Your comment on 'Test document' is now published"
     122        self.checkToANDSubj(mails, to="owner@test.com", subj="[PREFIX] New comment added") 
     123        self.checkToANDSubj(mails, to="replier1@test.com", subj='Your comment on "Test document" is now published'
    119124 
    120125    def test_Publish2ndReply(self): 
     
    133138        mails = getMails() 
    134139        self.assertEqual(len(mails), 3) 
    135         self.checkToANDSubj(mails, to="owner@test.com", subj="New comment added") 
    136         self.checkToANDSubj(mails, to="replier1@test.com", subj="Someone replied to your comment on 'Test document'"
    137         self.checkToANDSubj(mails, to="replier2@test.com", subj="Your comment on 'Test document' is now published"
     140        self.checkToANDSubj(mails, to="owner@test.com", subj="[PREFIX] New comment added") 
     141        self.checkToANDSubj(mails, to="replier1@test.com", subj='Someone replied to your comment on "Test document"'
     142        self.checkToANDSubj(mails, to="replier2@test.com", subj='Your comment on "Test document" is now published'
    138143 
    139144    def test_DeleteReply(self): 
     
    147152        mails = getMails() 
    148153        self.assertEqual(len(mails), 1) 
    149         self.checkToANDSubj(mails, to="replier1@test.com", subj="Your comment on 'Test document' was not approved."
     154        self.checkToANDSubj(mails, to="replier1@test.com", subj='Your comment on "Test document" was not approved'
    150155 
    151156