Changeset 3384 in products


Ignore:
Timestamp:
Mar 28, 2012 1:54:01 PM (7 years ago)
Author:
fenix
Message:

added tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Products.MailHost/trunk/src/Products/MailHost/tests/testMailHost.py

    r3356 r3384  
    2727        self.sent = '' 
    2828    def _send(self, mfrom, mto, messageText, immediate=False): 
     29        self.mfrom = mfrom 
     30        self.mto = mto 
    2931        self.sent = messageText 
    3032        self.immediate = immediate 
     
    445447        # We need to make sure we didn't mutate the message we were passed 
    446448        self.failIfEqual(out.as_string(), msg.as_string()) 
    447         self.failUnlessEqual(out['From'], 'Foo Bar <foo@domain.com>') 
     449        self.failUnlessEqual(out['From'], 
     450            '=?utf-8?q?Jos=C3=A9_Andr=C3=A9s?= <jose@example.com>') 
    448451        self.failUnlessEqual(msg['From'], 
    449452            '=?utf-8?q?Jos=C3=A9_Andr=C3=A9s?= <jose@example.com>') 
     
    638641        self.assertEqual(mailhost.sent, msg) 
    639642 
     643    def testSMTPMailFromHeaderSetup(self): 
     644        msg = message_from_string("""\ 
     645From: =?utf-8?q?Jos=C3=A9_Andr=C3=A9s?= <jose@example.com> 
     646To: =?utf-8?q?Ferran_Adri=C3=A0?= <ferran@example.com> 
     647Subject: =?utf-8?q?=C2=BFEsferificaci=C3=B3n=3F?= 
     648Date: Sun, 27 Aug 2006 17:00:00 +0200 
     649Content-Type: text/html; charset="utf-8" 
     650Content-Transfer-Encoding: base64 
     651MIME-Version: 1.1 
     652 
     653wqFVbiB0cnVjbyA8c3Ryb25nPmZhbnTDoXN0aWNvPC9zdHJvbmc+IQ=3D=3D 
     654""") 
     655        mailhost = self._makeOne('MailHost') 
     656        mailhost.send(msg, mfrom='Foo Bar <foo@domain.com>') 
     657        out = message_from_string(mailhost.sent) 
     658 
     659        # We need to check if the 'From' header in message that we passed 
     660        # haven't changed. 
     661        self.failUnlessEqual(out['From'], msg['From']) 
     662 
     663        # We need to make sure that proper 'SMTP MAIL FROM' header was send. 
     664        self.failUnlessEqual(mailhost.mfrom, 'Foo Bar <foo@domain.com>') 
     665 
     666        # If 'From' header is missing in the message 
     667        # it should be added with 'MAIL FROM' SMTP Envelope header value. 
     668        del msg['From'] 
     669        mailhost.send(msg, mfrom='Foo Bar <foo@domain.com>') 
     670        out = message_from_string(mailhost.sent) 
     671        self.failUnlessEqual(out['From'], 'Foo Bar <foo@domain.com>') 
     672 
    640673 
    641674def test_suite(): 
Note: See TracChangeset for help on using the changeset viewer.