/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: 2018-07-24 21:28:01 UTC
  • mto: This revision was merged to the branch mainline in revision 7054.
  • Revision ID: jelmer@jelmer.uk-20180724212801-6iyzat2kra0rw1um
Fix remaining smtp tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
132
132
        user = 'joe'
133
133
        password = 'hispass'
134
134
        factory = WideOpenSMTPFactory()
135
 
        conn = self.get_connection(b'[DEFAULT]\nsmtp_username=%s\n' % user,
136
 
                                   smtp_factory=factory)
 
135
        conn = self.get_connection(
 
136
                b'[DEFAULT]\nsmtp_username=%s\n' % user.encode('ascii'),
 
137
                smtp_factory=factory)
137
138
        self.assertIs(None, conn._smtp_password)
138
139
 
139
140
        ui.ui_factory = ui.CannedInputUIFactory([password])
144
145
        user = 'joe'
145
146
        password = 'hispass'
146
147
        factory = WideOpenSMTPFactory()
147
 
        conn = self.get_connection(b'[DEFAULT]\nsmtp_username=%s\n' % user,
148
 
                                   smtp_factory=factory)
 
148
        conn = self.get_connection(
 
149
            b'[DEFAULT]\nsmtp_username=%s\n' % user.encode('ascii'),
 
150
            smtp_factory=factory)
149
151
        self.assertEqual(user, conn._smtp_username)
150
152
        self.assertIs(None, conn._smtp_password)
151
153
        # Create a config file with the right password
173
175
                          ('has_extn', 'starttls'),
174
176
                          ('login', user, utf8_pass)], factory._calls)
175
177
        smtp_username, smtp_password = factory._calls[-1][1:]
176
 
        self.assertIsInstance(smtp_username, str)
177
 
        self.assertIsInstance(smtp_password, str)
 
178
        self.assertIsInstance(smtp_username, bytes)
 
179
        self.assertIsInstance(smtp_password, bytes)
178
180
 
179
181
    def test_create_connection(self):
180
182
        factory = StubSMTPFactory()
261
263
        msg['From'] = '"J. Random Developer" <jrandom@example.com>'
262
264
        self.assertRaises(
263
265
            smtp_connection.NoDestinationAddress,
264
 
            smtp_connection.SMTPConnection(config.MemoryStack("")
 
266
            smtp_connection.SMTPConnection(config.MemoryStack(b"")
265
267
                                           ).send_email, msg)
266
268
 
267
269
        msg = email_message.EmailMessage('from@from.com', '', 'subject')
268
270
        self.assertRaises(
269
271
            smtp_connection.NoDestinationAddress,
270
 
            smtp_connection.SMTPConnection(config.MemoryStack("")
 
272
            smtp_connection.SMTPConnection(config.MemoryStack(b"")
271
273
                                           ).send_email, msg)
272
274
 
273
275
        msg = email_message.EmailMessage('from@from.com', [], 'subject')
274
276
        self.assertRaises(
275
277
            smtp_connection.NoDestinationAddress,
276
 
            smtp_connection.SMTPConnection(config.MemoryStack("")
 
278
            smtp_connection.SMTPConnection(config.MemoryStack(b"")
277
279
                                           ).send_email, msg)