Merge lp:~elopio/u1-test-utils/fix1199098-delete_empty_inbox into lp:u1-test-utils

Proposed by Leo Arias
Status: Merged
Approved by: Natalia Bidart
Approved revision: 92
Merged at revision: 88
Proposed branch: lp:~elopio/u1-test-utils/fix1199098-delete_empty_inbox
Merge into: lp:u1-test-utils
Diff against target: 28 lines (+8/-2)
2 files modified
u1testutils/mail.py (+3/-2)
u1testutils/selftests/unit/test_mail.py (+5/-0)
To merge this branch: bzr merge lp:~elopio/u1-test-utils/fix1199098-delete_empty_inbox
Reviewer Review Type Date Requested Status
Natalia Bidart Approve
Review via email: mp+173566@code.launchpad.net

Commit message

Delete the messages only if they are present.

To post a comment you must log in.
90. By Leo Arias

Added a comment about the added test.

91. By Leo Arias

Fixed pep8.

92. By Leo Arias

Fixed flakes.

Revision history for this message
Natalia Bidart (nataliabidart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'u1testutils/mail.py'
2--- u1testutils/mail.py 2013-01-18 18:53:55 +0000
3+++ u1testutils/mail.py 2013-07-08 19:01:25 +0000
4@@ -104,8 +104,9 @@
5 def delete_msgs_sent_to(self, email_address):
6 self.imap.select('Inbox')
7 status, data = self.imap.search(None, 'TO', email_address)
8- if status == 'OK':
9- for num in reversed(data[0].split()):
10+ message_numbers = data[0]
11+ if status == 'OK' and message_numbers is not None:
12+ for num in reversed(message_numbers.split()):
13 status, data = self.imap.fetch(num, '(RFC822)')
14 self.imap.store(num, '+FLAGS', r'\Deleted')
15 self.imap.expunge()
16
17=== modified file 'u1testutils/selftests/unit/test_mail.py'
18--- u1testutils/selftests/unit/test_mail.py 2013-07-02 16:51:41 +0000
19+++ u1testutils/selftests/unit/test_mail.py 2013-07-08 19:01:25 +0000
20@@ -69,3 +69,8 @@
21 self.assertEquals(latest_email['Subject'], message['Subject'])
22 self.assertEquals(
23 latest_email.get_payload(), message.get_payload() + '\n')
24+
25+ def test_delete_message_with_no_messages(self):
26+ # Test for bug #1199098.
27+ # It should not throw an exception.
28+ mail.delete_msgs_sent_to('i-have-no-messages@example.com')

Subscribers

People subscribed via source and target branches

to all changes: