/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_smtp_connection.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
class StubSMTPFactory(object):
43
43
    """A fake SMTP connection to test the connection setup."""
 
44
 
44
45
    def __init__(self, fail_on=None, smtp_features=None):
45
46
        self._fail_on = fail_on or []
46
47
        self._calls = []
133
134
        password = 'hispass'
134
135
        factory = WideOpenSMTPFactory()
135
136
        conn = self.get_connection(
136
 
                b'[DEFAULT]\nsmtp_username=%s\n' % user.encode('ascii'),
137
 
                smtp_factory=factory)
 
137
            b'[DEFAULT]\nsmtp_username=%s\n' % user.encode('ascii'),
 
138
            smtp_factory=factory)
138
139
        self.assertIs(None, conn._smtp_password)
139
140
 
140
141
        ui.ui_factory = ui.CannedInputUIFactory([password])
153
154
        # Create a config file with the right password
154
155
        conf = config.AuthenticationConfig()
155
156
        conf._get_config().update({'smtptest':
156
 
                                       {'scheme': 'smtp', 'user':user,
157
 
                                        'password': password}})
 
157
                                   {'scheme': 'smtp', 'user': user,
 
158
                                    'password': password}})
158
159
        conf._save()
159
160
 
160
161
        conn._connect()
244
245
        from_, to = smtp_connection.SMTPConnection.get_message_addresses(msg)
245
246
        self.assertEqual('jrandom@example.com', from_)
246
247
        self.assertEqual(sorted(['john@doe.com', 'jane@doe.com',
247
 
            'pperez@ejemplo.com', 'user@localhost']), sorted(to))
 
248
                                 'pperez@ejemplo.com', 'user@localhost']), sorted(to))
248
249
 
249
250
        # now with breezy's EmailMessage
250
251
        msg = email_message.EmailMessage(
251
252
            '"J. Random Developer" <jrandom@example.com>',
252
253
            ['John Doe <john@doe.com>', 'Jane Doe <jane@doe.com>',
253
 
             u'Pepe P\xe9rez <pperez@ejemplo.com>', 'user@localhost' ],
 
254
             u'Pepe P\xe9rez <pperez@ejemplo.com>', 'user@localhost'],
254
255
            'subject')
255
256
 
256
257
        from_, to = smtp_connection.SMTPConnection.get_message_addresses(msg)
257
258
        self.assertEqual('jrandom@example.com', from_)
258
259
        self.assertEqual(sorted(['john@doe.com', 'jane@doe.com',
259
 
            'pperez@ejemplo.com', 'user@localhost']), sorted(to))
 
260
                                 'pperez@ejemplo.com', 'user@localhost']), sorted(to))
260
261
 
261
262
    def test_destination_address_required(self):
262
263
        msg = Message()