diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-01-28 16:09:04 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-01-28 16:09:09 -0300 |
commit | 2652238050640d7984f9464a9487d960133af19f (patch) | |
tree | 7f8998f31de534b420e78e9b689b6677a7762856 | |
parent | 188a0d0f3c8fcc3160c8b9480ebd7078a89f178c (diff) |
for #173, now searching on sender field for contacts auto complete
-rw-r--r-- | service/pixelated/adapter/search/__init__.py | 5 | ||||
-rw-r--r-- | service/test/integration/test_contacts.py | 11 | ||||
-rw-r--r-- | service/test/support/integration/model.py | 1 |
3 files changed, 16 insertions, 1 deletions
diff --git a/service/pixelated/adapter/search/__init__.py b/service/pixelated/adapter/search/__init__.py index 688fa4d3..a327c62e 100644 --- a/service/pixelated/adapter/search/__init__.py +++ b/service/pixelated/adapter/search/__init__.py @@ -202,6 +202,7 @@ class SearchEngine(object): to = QueryParser('to', self._index.schema) cc = QueryParser('cc', self._index.schema) bcc = QueryParser('bcc', self._index.schema) + sender = QueryParser('sender', self._index.schema) with self._index.searcher() as searcher: to = searcher.search(to.parse("*%s*" % query), limit=None, mask=restrict_q, groupedby=sorting.FieldFacet('to', allow_overlap=True)).groups() @@ -209,6 +210,8 @@ class SearchEngine(object): groupedby=sorting.FieldFacet('cc', allow_overlap=True)).groups() bcc = searcher.search(bcc.parse("*%s*" % query), limit=None, mask=restrict_q, groupedby=sorting.FieldFacet('bcc', allow_overlap=True)).groups() - return flatten([to, cc, bcc]) + sender = searcher.search(sender.parse("*%s*" % query), limit=None, mask=restrict_q, + groupedby=sorting.FieldFacet('sender', allow_overlap=True)).groups() + return flatten([to, cc, bcc, sender]) return [] diff --git a/service/test/integration/test_contacts.py b/service/test/integration/test_contacts.py index bfa91ea4..1a471440 100644 --- a/service/test/integration/test_contacts.py +++ b/service/test/integration/test_contacts.py @@ -34,6 +34,17 @@ class ContactsTest(SoledadTestBase): d.addCallback(_assert) return d + def test_FROM_address_is_being_searched(self): + input_mail = MailBuilder().with_tags(['important']).build_input_mail() + self.client.add_mail_to_inbox(input_mail) + + d = self.get_contacts(query='Sender') + + def _assert(contacts): + self.assertIn('Formatted Sender <sender@from.com>', contacts) + d.addCallback(_assert) + return d + def test_trash_and_drafts_mailboxes_are_being_ignored(self): self.client.add_multiple_to_mailbox(1, mailbox='INBOX', to='recipient@inbox.com') self.client.add_multiple_to_mailbox(1, mailbox='DRAFTS', to='recipient@drafts.com') diff --git a/service/test/support/integration/model.py b/service/test/support/integration/model.py index ea5dcad0..e90a3ec5 100644 --- a/service/test/support/integration/model.py +++ b/service/test/support/integration/model.py @@ -31,6 +31,7 @@ class MailBuilder: 'body': "Hello,\nThis is the body of this message\n\nRegards,\n\n--\nPixelated.\n", 'status': [] } + InputMail.FROM_EMAIL_ADDRESS = 'Formatted Sender <sender@from.com>' def with_body(self, body): self.mail['body'] = body |