From adf76a77fd158327b8d9a6f151cb7126a0397738 Mon Sep 17 00:00:00 2001 From: Duda Dornelles Date: Wed, 22 Oct 2014 15:58:29 +0200 Subject: index mails to accept a callback so that we can mark all as not recent when we are done indexing mails --- service/test/integration/soledad_querier_test.py | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 service/test/integration/soledad_querier_test.py (limited to 'service/test/integration') diff --git a/service/test/integration/soledad_querier_test.py b/service/test/integration/soledad_querier_test.py new file mode 100644 index 00000000..3c1ce6e1 --- /dev/null +++ b/service/test/integration/soledad_querier_test.py @@ -0,0 +1,57 @@ +# +# Copyright (c) 2014 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see . + +import copy +import unittest +import time +from test.support.integration_helper import SoledadTestBase +from leap.mail.imap.fields import WithMsgFields + + +class SoledadQuerierTest(unittest.TestCase, SoledadTestBase, WithMsgFields): + + def setUp(self): + self.setup_soledad() + + def tearDown(self): + self.teardown_soledad() + + def _get_empty_mailbox(self): + return copy.deepcopy(self.EMPTY_MBOX) + + def _create_mailbox(self, mailbox_name): + new_mailbox = self._get_empty_mailbox() + new_mailbox['mbox'] = mailbox_name + new_mailbox['created'] = int(time.time() * 10E2) + return self.soledad.create_doc(new_mailbox) + + def _get_mailboxes_from_soledad(self, mailbox_name): + return [m for m in self.soledad.get_from_index('by-type', 'mbox') if m.content['mbox'] == mailbox_name] + + def test_remove_dup_mailboxes_keeps_the_one_with_the_highest_last_uid(self): + self.add_multiple_to_mailbox(3, 'INBOX') # by now we already have one inbox with 3 mails + self._create_mailbox('INBOX') # now we have a duplicate + + # make sure we have two + inboxes = self._get_mailboxes_from_soledad('INBOX') + self.assertEqual(2, len(inboxes)) + + self.soledad_querier.remove_duplicates() + + # make sure we only have one, and the one with the right lastuid + inboxes = self._get_mailboxes_from_soledad('INBOX') + self.assertEqual(1, len(inboxes)) + self.assertEqual(3, inboxes[0].content['lastuid']) -- cgit v1.2.3