Skip to content

Commit

Permalink
Add query uid__range
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumit Ghosh committed Sep 8, 2018
1 parent d0b3fa4 commit 5a52df8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions imbox/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def build_search_query(**kwargs):
date__lt = kwargs.get('date__lt', False)
date__on = kwargs.get('date__on', False)
subject = kwargs.get('subject')
uid__range = kwargs.get('uid__range')

query = []

Expand Down Expand Up @@ -53,6 +54,9 @@ def build_search_query(**kwargs):
if subject is not None:
query.append('(SUBJECT "%s")' % subject)

if uid__range:
query.append('(UID %s)' % uid__range)

if query:
logger.debug("IMAP query: {}".format(" ".join(query)))
return " ".join(query)
Expand Down
4 changes: 4 additions & 0 deletions tests/query_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ def test_date__lt(self):
def test_date__on(self):
res = build_search_query(date__on=date(2014, 1, 1))
self.assertEqual(res, '(ON "01-Jan-2014")')

def test_uid__range(self):
res = build_search_query(uid__range='1000:*')
self.assertEqual(res, '(UID 1000:*)')

0 comments on commit 5a52df8

Please sign in to comment.