/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: James Henstridge
  • Date: 2009-03-16 07:24:59 UTC
  • mto: This revision was merged to the branch mainline in revision 4203.
  • Revision ID: james@jamesh.id.au-20090316072459-b26rgmv3lln2j8he
Ensure that byte strings are passed to SMTP.login(), as passing unicode 
does not make sense and breaks in Python 2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
    """A fake smtp server that implements login by accepting anybody."""
87
87
 
88
88
    def login(self, user, password):
89
 
        pass
 
89
        self._calls.append(('login', user, password))
90
90
 
91
91
 
92
92
class TestSMTPConnection(tests.TestCaseInTempDir):
162
162
        conn._connect()
163
163
        self.assertEqual(password, conn._smtp_password)
164
164
 
 
165
    def test_authenticate_with_byte_strings(self):
 
166
        user = 'joe'
 
167
        password = 'hispass'
 
168
        factory = WideOpenSMTPFactory()
 
169
        conn = self.get_connection(
 
170
            '[DEFAULT]\nsmtp_username=%s\nsmtp_password=%s\n'
 
171
            % (user, password), smtp_factory=factory)
 
172
        conn._connect()
 
173
        self.assertEqual([('connect', 'localhost'),
 
174
                          ('ehlo',),
 
175
                          ('has_extn', 'starttls'),
 
176
                          ('login', user, password)], factory._calls)
 
177
        smtp_user, smtp_password = factory._calls[-1][1:]
 
178
        self.assertIsInstance(smtp_user, str)
 
179
        self.assertIsInstance(smtp_password, str)
 
180
 
165
181
    def test_create_connection(self):
166
182
        factory = StubSMTPFactory()
167
183
        conn = self.get_connection('', smtp_factory=factory)