Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arnisoph committed Dec 20, 2015
1 parent 86e67bf commit a554919
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tests/integration/test_imap.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ def test_connect(self):

# Test connection refused
username, password = self.create_imap_user()
self.assertEqual(imap.IMAP(logger=self.logger,
server='127.0.0.1',
port=1337,
starttls=False,
imaps=True,
tlsverify=False, # TODO test tls verification?
username=username,
password=password).connect(), (False, '[Errno 61] Connection refused'))
self.assertTrue(imap.IMAP(logger=self.logger,
server='127.0.0.1',
port=1337,
starttls=False,
imaps=True,
tlsverify=False, # TODO test tls verification?
username=username,
password=password).connect()[1], '] Connection refused')

def test_process_error(self):
try:
Expand All @@ -88,6 +88,7 @@ def test_process_error(self):
def test_list_mailboxes(self):
username, password = self.create_imap_user()
imapconn = self.create_basic_imap_object(username, password)

self.assertEqual(imapconn.connect(), (True, b'Logged in'))

expect = [{'delimiter': '/',
Expand All @@ -106,6 +107,9 @@ def test_list_mailboxes(self):

self.assertEqual(imapconn.disconnect(), (True, b'Logging out'))

# Test exception handling
self.assertEqual(imapconn.list_mailboxes(), (False, 'command LIST illegal in state LOGOUT, only allowed in states AUTH, SELECTED'))

def test_select_mailbox(self):
username, password = self.create_imap_user()
imapconn = self.create_basic_imap_object(username, password)
Expand Down Expand Up @@ -153,7 +157,7 @@ def test_search_mail(self): # TODO see meth impl
self.assertEqual(imapconn.search_mails(mailbox='INBOX', criteria='SINCE 13-Apr-2015')[1], [1, 2])
self.assertRaises(RuntimeError, imapconn.search_mails, mailbox='DoesNotExist', criteria='ALL') # tests do_select_mailbox
self.assertRaises(AttributeError, imapconn.search_mails, 'DoesNotExist', criteria='ALL') # tests do_select_mailbox
self.assertRaises(AttributeError, imapconn.search_mails, criteria='ALL') # tests do_select_mailbox
self.assertRaises(KeyError, imapconn.search_mails, criteria='ALL') # tests do_select_mailbox
self.assertEqual(imapconn.search_mails(mailbox='INBOX',
criteria='DoesNotExist')[1],
'SEARCH command error: BAD [b\'Error in IMAP command UID SEARCH: Unknown argument DOESNOTEXIST\']')
Expand Down

0 comments on commit a554919

Please sign in to comment.