~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smtp_connection.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-06-28 07:08:27 UTC
  • mfrom: (2553.1.3 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070628070827-h5s313dg5tnag9vj
(robertc) Show the names of commit hooks during commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from email.Message import Message
19
19
 
20
20
from bzrlib import config
21
 
from bzrlib.email_message import EmailMessage
22
21
from bzrlib.errors import NoDestinationAddress
23
22
from bzrlib.tests import TestCase
24
23
from bzrlib.smtp_connection import SMTPConnection
73
72
        self.assertEqual(sorted(['john@doe.com', 'jane@doe.com',
74
73
            'pperez@ejemplo.com', 'user@localhost']), sorted(to))
75
74
 
76
 
        # now with bzrlib's EmailMessage
77
 
        msg = EmailMessage('"J. Random Developer" <jrandom@example.com>', [
78
 
            'John Doe <john@doe.com>', 'Jane Doe <jane@doe.com>',
79
 
            u'Pepe P\xe9rez <pperez@ejemplo.com>', 'user@localhost' ],
80
 
            'subject')
81
 
 
82
 
        from_, to = SMTPConnection.get_message_addresses(msg)
83
 
        self.assertEqual('jrandom@example.com', from_)
84
 
        self.assertEqual(sorted(['john@doe.com', 'jane@doe.com',
85
 
            'pperez@ejemplo.com', 'user@localhost']), sorted(to))
86
 
 
87
75
    def test_destination_address_required(self):
88
76
        class FakeConfig:
89
77
            def get_user_option(self, option):
93
81
        msg['From'] = '"J. Random Developer" <jrandom@example.com>'
94
82
        self.assertRaises(NoDestinationAddress,
95
83
                SMTPConnection(FakeConfig()).send_email, msg)
96
 
 
97
 
        msg = EmailMessage('from@from.com', '', 'subject')
98
 
        self.assertRaises(NoDestinationAddress,
99
 
                SMTPConnection(FakeConfig()).send_email, msg)
100
 
 
101
 
        msg = EmailMessage('from@from.com', [], 'subject')
102
 
        self.assertRaises(NoDestinationAddress,
103
 
                SMTPConnection(FakeConfig()).send_email, msg)