Exemplo n.º 1
0
 def test_recipients(self):
     """To/Cc recipients"""
     ticket = Ticket(self.env)
     ticket['reporter'] = '"Joe User" <*****@*****.**>'
     ticket['owner']    = '*****@*****.**'
     ticket['cc']       = '[email protected], [email protected], ' \
                          '*****@*****.**'
     ticket['summary'] = 'Foo'
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     recipients = notifysuite.smtpd.get_recipients()
     # checks there is no duplicate in the recipient list
     rcpts = []
     for r in recipients:
         self.failIf(r in rcpts)
         rcpts.append(r)
     # checks that all cc recipients have been notified
     cc_list = self.env.config.get('notification', 'smtp_always_cc')
     cc_list = "%s, %s" % (cc_list, ticket['cc'])
     for r in cc_list.replace(',', ' ').split():
         self.failIf(r not in recipients)
     # checks that owner has been notified
     self.failIf(smtp_address(ticket['owner']) not in recipients)
     # checks that reporter has been notified
     self.failIf(smtp_address(ticket['reporter']) not in recipients)
 def test_recipients(self):
     """To/Cc recipients"""
     ticket = Ticket(self.env)
     ticket['reporter'] = '"Joe User" < *****@*****.** >'
     ticket['owner'] = '*****@*****.**'
     ticket['cc']       = '[email protected], [email protected], ' \
                          '*****@*****.**'
     ticket['summary'] = 'Foo'
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     recipients = notifysuite.smtpd.get_recipients()
     # checks there is no duplicate in the recipient list
     rcpts = []
     for r in recipients:
         self.failIf(r in rcpts)
         rcpts.append(r)
     # checks that all cc recipients have been notified
     cc_list = self.env.config.get('notification', 'smtp_always_cc')
     cc_list = "%s, %s" % (cc_list, ticket['cc'])
     for r in cc_list.replace(',', ' ').split():
         self.failIf(r not in recipients)
     # checks that owner has been notified
     self.failIf(smtp_address(ticket['owner']) not in recipients)
     # checks that reporter has been notified
     self.failIf(smtp_address(ticket['reporter']) not in recipients)
 def test_recipients(self):
     """To/Cc recipients"""
     db = self.env.get_db_cnx()
     cursor = db.cursor()
     cursor.executemany("INSERT INTO permission VALUES (%s,%s)", [
                        ('*****@*****.**', 'SENSITIVE_VIEW'), 
                        ('*****@*****.**', 'SENSITIVE_VIEW'), 
                        ('*****@*****.**', 'SENSITIVE_VIEW'), 
                        ])
     ticket = Ticket(self.env)
     ticket['reporter'] = '*****@*****.**'
     ticket['owner']    = '*****@*****.**'
     ticket['cc']       = '[email protected], [email protected], ' \
                          '*****@*****.**'
     ticket['summary'] = 'Foo'
     ticket['sensitive'] = '1'
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     recipients = self.smtpd.get_recipients()
     # checks there is no duplicate in the recipient list
     rcpts = []
     for r in recipients:
         self.failIf(r in rcpts)
         rcpts.append(r)
     # checks that all cc recipients have been notified
     cc_list = self.env.config.get('notification', 'smtp_always_cc')
     cc_list = "%s, %s" % (cc_list, ticket['cc'])
     for r in cc_list.replace(',', ' ').split():
         if 'customer' in r:
             self.failIf(r in recipients)
         else:
             self.failIf(r not in recipients)
     # checks that owner has not been notified
     self.failIf(smtp_address(ticket['owner']) not in recipients)
     # checks that reporter has not been notified (is a customer)
     self.failIf(smtp_address(ticket['reporter']) in recipients)