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
=== modified file 'u1testutils/mail.py'
--- u1testutils/mail.py 2013-01-18 18:53:55 +0000
+++ u1testutils/mail.py 2013-07-08 19:01:25 +0000
@@ -104,8 +104,9 @@
104 def delete_msgs_sent_to(self, email_address):104 def delete_msgs_sent_to(self, email_address):
105 self.imap.select('Inbox')105 self.imap.select('Inbox')
106 status, data = self.imap.search(None, 'TO', email_address)106 status, data = self.imap.search(None, 'TO', email_address)
107 if status == 'OK':107 message_numbers = data[0]
108 for num in reversed(data[0].split()):108 if status == 'OK' and message_numbers is not None:
109 for num in reversed(message_numbers.split()):
109 status, data = self.imap.fetch(num, '(RFC822)')110 status, data = self.imap.fetch(num, '(RFC822)')
110 self.imap.store(num, '+FLAGS', r'\Deleted')111 self.imap.store(num, '+FLAGS', r'\Deleted')
111 self.imap.expunge()112 self.imap.expunge()
112113
=== modified file 'u1testutils/selftests/unit/test_mail.py'
--- u1testutils/selftests/unit/test_mail.py 2013-07-02 16:51:41 +0000
+++ u1testutils/selftests/unit/test_mail.py 2013-07-08 19:01:25 +0000
@@ -69,3 +69,8 @@
69 self.assertEquals(latest_email['Subject'], message['Subject'])69 self.assertEquals(latest_email['Subject'], message['Subject'])
70 self.assertEquals(70 self.assertEquals(
71 latest_email.get_payload(), message.get_payload() + '\n')71 latest_email.get_payload(), message.get_payload() + '\n')
72
73 def test_delete_message_with_no_messages(self):
74 # Test for bug #1199098.
75 # It should not throw an exception.
76 mail.delete_msgs_sent_to('i-have-no-messages@example.com')

Subscribers

People subscribed via source and target branches

to all changes: