date__gt, date__lt can be datetime.date objects; added tests for build_search_query
This commit is contained in:
36
tests/query_tests.py
Normal file
36
tests/query_tests.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import unittest
|
||||
from imbox.query import build_search_query
|
||||
from datetime import date
|
||||
|
||||
|
||||
class TestQuery(unittest.TestCase):
|
||||
|
||||
def test_all(self):
|
||||
|
||||
res = build_search_query()
|
||||
self.assertEqual(res, "(ALL)")
|
||||
|
||||
def test_unread(self):
|
||||
|
||||
res = build_search_query(unread=True)
|
||||
self.assertEqual(res, "(UNSEEN)")
|
||||
|
||||
def test_sent_from(self):
|
||||
|
||||
res = build_search_query(sent_from='test@example.com')
|
||||
self.assertEqual(res, "(FROM \"test@example.com\")")
|
||||
|
||||
def test_sent_to(self):
|
||||
|
||||
res = build_search_query(sent_to='test@example.com')
|
||||
self.assertEqual(res, "(TO \"test@example.com\")")
|
||||
|
||||
def test_date__gt(self):
|
||||
|
||||
res = build_search_query(date__gt=date(2014, 12, 31))
|
||||
self.assertEqual(res, "(SINCE \"31-Dec-2014\")")
|
||||
|
||||
def test_date__lt(self):
|
||||
|
||||
res = build_search_query(date__lt=date(2014, 1, 1))
|
||||
self.assertEqual(res, "(BEFORE \"1-Jan-2014\")")
|
||||
Reference in New Issue
Block a user