summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorBruno Wagner <bwagner@thoughtworks.com>2014-10-16 11:53:56 +0200
committerBruno Wagner <bwagner@thoughtworks.com>2014-10-16 11:53:56 +0200
commiteacd5fd5f7f47791ddc2e5568b8e4622420d8562 (patch)
treef303e7593c8eec8cc626b0df489b7e81128ca6dd /service/test
parent693957054255b1807ae9c09478a06e191114b7fb (diff)
#96 Mail searches are now paginated, the pages number start at 1 now
Diffstat (limited to 'service/test')
-rw-r--r--service/test/integration/search_test.py30
-rw-r--r--service/test/support/integration_helper.py4
2 files changed, 32 insertions, 2 deletions
diff --git a/service/test/integration/search_test.py b/service/test/integration/search_test.py
index 7323866d..81d1fad2 100644
--- a/service/test/integration/search_test.py
+++ b/service/test/integration/search_test.py
@@ -58,3 +58,33 @@ class SearchTest(unittest.TestCase, SoledadTestBase):
all_tag_names = [t['name'] for t in all_tags]
self.assertEqual(1, len(all_tag_names))
self.assertTrue('sometag' in all_tag_names)
+
+ def test_search_mails_different_window(self):
+ input_mail = MailBuilder().build_input_mail()
+ input_mail2 = MailBuilder().build_input_mail()
+ self.add_mail_to_inbox(input_mail)
+ self.add_mail_to_inbox(input_mail2)
+
+ first_page = self.get_mails_by_tag('inbox', page=1, window=1)
+
+ self.assertEqual(len(first_page), 1)
+
+ def test_search_mails_with_multiple_pages(self):
+ input_mail = MailBuilder().build_input_mail()
+ input_mail2 = MailBuilder().build_input_mail()
+ self.add_mail_to_inbox(input_mail)
+ self.add_mail_to_inbox(input_mail2)
+
+ first_page = self.get_mails_by_tag('inbox', page=1, window=1)
+ second_page = self.get_mails_by_tag('inbox', page=2, window=1)
+
+ idents = [input_mail.ident, input_mail2.ident]
+
+ self.assertIn(first_page[0].ident, idents)
+ self.assertIn(second_page[0].ident, idents)
+
+ def test_page_zero_fetches_first_page(self):
+ input_mail = MailBuilder().build_input_mail()
+ self.add_mail_to_inbox(input_mail)
+ page = self.get_mails_by_tag('inbox', page=0, window=1)
+ self.assertEqual(page[0].ident, input_mail.ident)
diff --git a/service/test/support/integration_helper.py b/service/test/support/integration_helper.py
index 268eb812..f0f3b02a 100644
--- a/service/test/support/integration_helper.py
+++ b/service/test/support/integration_helper.py
@@ -173,8 +173,8 @@ class SoledadTestBase:
app_factory._setup_routes(self.client.application, home_controller, mails_controller, tags_controller,
features_controller)
- def get_mails_by_tag(self, tag):
- response = json.loads(self.client.get("/mails?q=tag:" + tag).data)
+ def get_mails_by_tag(self, tag, page=1, window=100):
+ response = json.loads(self.client.get("/mails?q=tag:%s&w=%s&p=%s" % (tag, window, page)).data)
return [ResponseMail(m) for m in response['mails']]
def post_mail(self, data):