Skip to content

Commit 2885ef1

Browse files
committed
Bugfixes.
- Multi-words email subject search bugfixes - Adjust documentation - Adjust test cases
1 parent 423b89e commit 2885ef1

File tree

5 files changed

+38
-18
lines changed

5 files changed

+38
-18
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
0.2.3 (2016.01.19)
2+
==================
3+
4+
* Multi-words email subject search bugfixes
5+
* Adjust documentation
6+
* Adjust test cases
7+
18
0.2.2 (2016.01.19)
29
==================
310

doc/ImapLibrary.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/ImapLibrary/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ def wait_for_email(self, **kwargs):
294294
``UIDVALIDITY``, and ``UNSEEN``.
295295
Please see [https://goo.gl/3KKHoY|Mailbox Status] for more information.
296296
(Default None)
297+
- ``subject``: Email subject. (Default None)
297298
- ``text``: Email body text. (Default None)
298299
- ``timeout``: The maximum value in seconds to wait for email message to arrived.
299300
(Default 60)
@@ -364,13 +365,13 @@ def _criteria(**kwargs):
364365
subject = kwargs.pop('subject', None)
365366
text = kwargs.pop('text', None)
366367
if recipient:
367-
criteria += ['TO', recipient]
368+
criteria += ['TO', '"%s"' % recipient]
368369
if sender:
369-
criteria += ['FROM', sender]
370+
criteria += ['FROM', '"%s"' % sender]
370371
if subject:
371-
criteria += ['SUBJECT', subject]
372+
criteria += ['SUBJECT', '"%s"' % subject]
372373
if text:
373-
criteria += ['TEXT', text]
374+
criteria += ['TEXT', '"%s"' % text]
374375
if status:
375376
criteria += [status]
376377
if not criteria:

src/ImapLibrary/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
IMAP Library - a IMAP email testing library.
2020
"""
2121

22-
VERSION = '0.2.2'
22+
VERSION = '0.2.3'
2323

2424

2525
def get_version():

test/utest/test_imaplibrary.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ def test_should_return_email_index(self, mock_imap):
108108
self.library._imap.search.return_value = ['OK', ['0']]
109109
index = self.library.wait_for_email(sender=self.sender)
110110
self.library._imap.select.assert_called_with()
111-
self.library._imap.search.assert_called_with(None, 'FROM', self.sender)
111+
self.library._imap.search.assert_called_with(None, 'FROM', '"%s"' %
112+
self.sender)
112113
self.assertEqual(index, '0')
113114

114115
@mock.patch('ImapLibrary.IMAP4_SSL')
@@ -122,15 +123,18 @@ def test_should_return_email_index_with_sender_filter(self, mock_imap):
122123
self.library._imap.search.return_value = ['OK', ['0']]
123124
index = self.library.wait_for_email(sender=self.sender)
124125
self.library._imap.select.assert_called_with()
125-
self.library._imap.search.assert_called_with(None, 'FROM', self.sender)
126+
self.library._imap.search.assert_called_with(None, 'FROM', '"%s"' %
127+
self.sender)
126128
self.assertEqual(index, '0')
127129
index = self.library.wait_for_email(from_email=self.sender)
128130
self.library._imap.select.assert_called_with()
129-
self.library._imap.search.assert_called_with(None, 'FROM', self.sender)
131+
self.library._imap.search.assert_called_with(None, 'FROM', '"%s"' %
132+
self.sender)
130133
self.assertEqual(index, '0')
131134
index = self.library.wait_for_email(fromEmail=self.sender)
132135
self.library._imap.select.assert_called_with()
133-
self.library._imap.search.assert_called_with(None, 'FROM', self.sender)
136+
self.library._imap.search.assert_called_with(None, 'FROM', '"%s"' %
137+
self.sender)
134138
self.assertEqual(index, '0')
135139

136140
@mock.patch('ImapLibrary.IMAP4_SSL')
@@ -144,15 +148,18 @@ def test_should_return_email_index_with_recipient_filter(self, mock_imap):
144148
self.library._imap.search.return_value = ['OK', ['0']]
145149
index = self.library.wait_for_email(recipient=self.recipient)
146150
self.library._imap.select.assert_called_with()
147-
self.library._imap.search.assert_called_with(None, 'TO', self.recipient)
151+
self.library._imap.search.assert_called_with(None, 'TO', '"%s"' %
152+
self.recipient)
148153
self.assertEqual(index, '0')
149154
index = self.library.wait_for_email(to_email=self.recipient)
150155
self.library._imap.select.assert_called_with()
151-
self.library._imap.search.assert_called_with(None, 'TO', self.recipient)
156+
self.library._imap.search.assert_called_with(None, 'TO', '"%s"' %
157+
self.recipient)
152158
self.assertEqual(index, '0')
153159
index = self.library.wait_for_email(toEmail=self.recipient)
154160
self.library._imap.select.assert_called_with()
155-
self.library._imap.search.assert_called_with(None, 'TO', self.recipient)
161+
self.library._imap.search.assert_called_with(None, 'TO', '"%s"' %
162+
self.recipient)
156163
self.assertEqual(index, '0')
157164

158165
@mock.patch('ImapLibrary.IMAP4_SSL')
@@ -166,7 +173,8 @@ def test_should_return_email_index_with_subject_filter(self, mock_imap):
166173
self.library._imap.search.return_value = ['OK', ['0']]
167174
index = self.library.wait_for_email(subject=self.subject)
168175
self.library._imap.select.assert_called_with()
169-
self.library._imap.search.assert_called_with(None, 'SUBJECT', self.subject)
176+
self.library._imap.search.assert_called_with(None, 'SUBJECT', '"%s"' %
177+
self.subject)
170178
self.assertEqual(index, '0')
171179

172180
@mock.patch('ImapLibrary.IMAP4_SSL')
@@ -178,7 +186,8 @@ def test_should_return_email_index_with_text_filter(self, mock_imap):
178186
self.library._imap.search.return_value = ['OK', ['0']]
179187
index = self.library.wait_for_email(text=self.text)
180188
self.library._imap.select.assert_called_with()
181-
self.library._imap.search.assert_called_with(None, 'TEXT', self.text)
189+
self.library._imap.search.assert_called_with(None, 'TEXT', '"%s"' %
190+
self.text)
182191
self.assertEqual(index, '0')
183192

184193
@mock.patch('ImapLibrary.IMAP4_SSL')
@@ -217,7 +226,8 @@ def test_should_return_email_index_from_deprecated_keyword(self, mock_imap):
217226
self.library._imap.search.return_value = ['OK', ['0']]
218227
index = self.library.wait_for_mail(sender=self.sender)
219228
self.library._imap.select.assert_called_with()
220-
self.library._imap.search.assert_called_with(None, 'FROM', self.sender)
229+
self.library._imap.search.assert_called_with(None, 'FROM', '"%s"' %
230+
self.sender)
221231
self.assertEqual(index, '0')
222232

223233
@mock.patch('ImapLibrary.IMAP4_SSL')
@@ -229,7 +239,8 @@ def test_should_return_email_index_after_delay(self, mock_imap):
229239
self.library._imap.search.side_effect = [['OK', ['']], ['OK', ['0']]]
230240
index = self.library.wait_for_email(sender=self.sender, poll_frequency=0.2)
231241
self.library._imap.select.assert_called_with()
232-
self.library._imap.search.assert_called_with(None, 'FROM', self.sender)
242+
self.library._imap.search.assert_called_with(None, 'FROM', '"%s"' %
243+
self.sender)
233244
self.assertEqual(index, '0')
234245

235246
@mock.patch('ImapLibrary.IMAP4_SSL')
@@ -268,7 +279,8 @@ def test_should_raise_exception_on_search_error(self, mock_imap):
268279
self.assertTrue("imap.search error: NOK, [''], criteria=['FROM', '%s']" %
269280
self.sender in context.exception)
270281
self.library._imap.select.assert_called_with()
271-
self.library._imap.search.assert_called_with(None, 'FROM', self.sender)
282+
self.library._imap.search.assert_called_with(None, 'FROM', '"%s"' %
283+
self.sender)
272284

273285
@mock.patch('ImapLibrary.IMAP4_SSL')
274286
def test_should_delete_all_emails(self, mock_imap):

0 commit comments

Comments
 (0)