Changeset 795

Show
Ignore:
Timestamp:
02/22/07 11:20:10
Author:
crchemist
Message:

Fix up bug with wrong names in mails.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneComments/trunk/tests/testQPloneCommentsNotification.py

    r794 r795  
    44 
    55import os, sys, string 
     6 
    67if __name__ == '__main__': 
    78    execfile(os.path.join(sys.path[0], 'framework.py')) 
     
    1112from Products.CMFCore.CMFCorePermissions import ManagePortal, ReplyToItem 
    1213from Products.MailHost.MailHost import MailBase 
     14 
     15import re 
     16 
     17from Products.qPloneComments.utils import getMsg 
    1318from helperNotify import * 
    1419 
     
    6873 
    6974        prepareMailSendTest() 
    70          
    71     def test_bug_parent_reply(self):            
     75 
     76    def test_bug_parent_reply(self): 
    7277        setProperties(self.prefs, 'enable_reply_user_notification') 
    7378        self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 
    7479        parent_reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 
    7580        parent_reply.discussion_reply('reply', 'text') 
    76          
     81 
    7782    def test_bug_mistakable_names(self): 
    78         """ 
    79         cleanOutputDir() 
    80         setProperties(self.prefs, 'enable_reply_user_notification') 
     83        setProperties(self.prefs, 'enable_reply_user_notification') 
    8184        self.my_doc.discussion_reply('A Reply for my_doc' ,'text of reply for my_doc') 
    8285        parent_reply = self.discussion.getDiscussionFor(self.my_doc).getReplies()[0] 
    83          
    84         parent_reply._delProperty('userid') 
    85          
    86         parent_reply.discussion_reply('reply', 'text') 
    87         """ 
     86 
     87        args={'mto': 'user_email@gmail.com', 
     88              'mfrom': 'admin_email@gmail.com', 
     89              'obj': parent_reply, 
     90              'organization_name': 'org_name', 
     91              'name': parent_reply.Creator()} 
     92 
     93        msg = getMsg(self.portal, 'reply_notify_template', args) 
     94        patt = re.compile('\\n\\n([^,]*)') 
     95        m = patt.search(msg) 
     96        if m: 
     97            name = m.group(1) 
     98            self.assertEqual(parent_reply.Creator(), name) 
     99        else: 
     100            raise "No name" 
    88101 
    89102    def test_notificafion_disabled(self): 
  • qPloneComments/trunk/utils.py

    r794 r795  
    4949        sendMails(props, actions, 'onApprove') 
    5050 
     51def getMsg(context, template, args): 
     52    return getattr(context, template)(**args) 
    5153 
    5254def send_email(reply, context, state): 
    53     def send(context, template, args): 
    54         msg = getattr(context, template)(**args) 
    55         return context.MailHost.send(msg) 
    56  
    5755    def getEmail(obj, context): 
    5856        email = obj.getProperty('email', None) 
     
    151149 
    152150    if args: 
    153         return send(context, template, args) 
    154     else: 
    155         return 1 
     151        msg = getMsg(context, template, args) 
     152        context.MailHost.send(msg)