/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 bzrlib/tests/test_smtp_connection.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
try:
18
 
    from email.message import Message
19
 
except ImportError:  # python < 3
20
 
    from email.Message import Message
 
17
from email.Message import Message
21
18
import errno
22
19
import smtplib
23
20
import socket
24
21
 
25
 
from breezy import (
 
22
from bzrlib import (
26
23
    config,
27
24
    email_message,
 
25
    errors,
28
26
    smtp_connection,
29
27
    tests,
30
28
    ui,
108
106
 
109
107
    def test_missing_server(self):
110
108
        conn = self.get_connection('', smtp_factory=connection_refuser)
111
 
        self.assertRaises(smtp_connection.DefaultSMTPConnectionRefused,
112
 
                          conn._connect)
 
109
        self.assertRaises(errors.DefaultSMTPConnectionRefused, conn._connect)
113
110
        conn = self.get_connection('smtp_server=smtp.example.com',
114
111
                                   smtp_factory=connection_refuser)
115
 
        self.assertRaises(smtp_connection.SMTPConnectionRefused, conn._connect)
 
112
        self.assertRaises(errors.SMTPConnectionRefused, conn._connect)
116
113
 
117
114
    def test_smtp_username(self):
118
115
        conn = self.get_connection('')
198
195
        # Check that we raise an exception if both EHLO and HELO fail.
199
196
        factory = StubSMTPFactory(fail_on=['ehlo', 'helo'])
200
197
        conn = self.get_connection('', smtp_factory=factory)
201
 
        self.assertRaises(smtp_connection.SMTPError, conn._create_connection)
 
198
        self.assertRaises(errors.SMTPError, conn._create_connection)
202
199
        self.assertEqual([('connect', 'localhost'),
203
200
                          ('ehlo',),
204
201
                          ('helo',)], factory._calls)
221
218
        factory = StubSMTPFactory(fail_on=['starttls'],
222
219
                                  smtp_features=['starttls'])
223
220
        conn = self.get_connection('', smtp_factory=factory)
224
 
        self.assertRaises(smtp_connection.SMTPError, conn._create_connection)
 
221
        self.assertRaises(errors.SMTPError, conn._create_connection)
225
222
        self.assertEqual([('connect', 'localhost'),
226
223
                          ('ehlo',),
227
224
                          ('has_extn', 'starttls'),
244
241
        self.assertEqual(sorted(['john@doe.com', 'jane@doe.com',
245
242
            'pperez@ejemplo.com', 'user@localhost']), sorted(to))
246
243
 
247
 
        # now with breezy's EmailMessage
 
244
        # now with bzrlib's EmailMessage
248
245
        msg = email_message.EmailMessage(
249
246
            '"J. Random Developer" <jrandom@example.com>',
250
247
            ['John Doe <john@doe.com>', 'Jane Doe <jane@doe.com>',
260
257
        msg = Message()
261
258
        msg['From'] = '"J. Random Developer" <jrandom@example.com>'
262
259
        self.assertRaises(
263
 
            smtp_connection.NoDestinationAddress,
 
260
            errors.NoDestinationAddress,
264
261
            smtp_connection.SMTPConnection(config.MemoryStack("")
265
262
                                           ).send_email, msg)
266
263
 
267
264
        msg = email_message.EmailMessage('from@from.com', '', 'subject')
268
265
        self.assertRaises(
269
 
            smtp_connection.NoDestinationAddress,
 
266
            errors.NoDestinationAddress,
270
267
            smtp_connection.SMTPConnection(config.MemoryStack("")
271
268
                                           ).send_email, msg)
272
269
 
273
270
        msg = email_message.EmailMessage('from@from.com', [], 'subject')
274
271
        self.assertRaises(
275
 
            smtp_connection.NoDestinationAddress,
 
272
            errors.NoDestinationAddress,
276
273
            smtp_connection.SMTPConnection(config.MemoryStack("")
277
274
                                           ).send_email, msg)