From 2bd46a719b947b0839f47fd9e4bf5517f396fd29 Mon Sep 17 00:00:00 2001 From: Patrick Maia Date: Fri, 20 Feb 2015 11:14:58 -0300 Subject: Issue #174 - rejects bounced addresses on contacts suggestions --- service/test/integration/test_contacts.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'service/test/integration/test_contacts.py') diff --git a/service/test/integration/test_contacts.py b/service/test/integration/test_contacts.py index c5baa094..d96abd14 100644 --- a/service/test/integration/test_contacts.py +++ b/service/test/integration/test_contacts.py @@ -14,6 +14,8 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . from test.support.integration import SoledadTestBase, MailBuilder +import os +import json class ContactsTest(SoledadTestBase): @@ -73,10 +75,37 @@ class ContactsTest(SoledadTestBase): d = self.get_contacts(query='Recipient') def _assert(contacts): - print contacts self.assertEquals(3, len(contacts)) self.assertTrue('Recipient Principal ' in contacts) self.assertTrue('Recipient Copied ' in contacts) self.assertTrue('Recipient Carbon ' in contacts) d.addCallback(_assert) return d + + def test_bounced_addresses_are_ignored(self): + to_be_bounced = MailBuilder().with_to('this_mail_was_bounced@domain.com').build_input_mail() + self.client.add_mail_to_inbox(to_be_bounced) + + bounced_mail_template = MailBuilder().build_input_mail() + bounced_mail = self.client.mailboxes.inbox().add(bounced_mail_template) + bounced_mail.hdoc.content = self._bounced_mail_hdoc_content() + bounced_mail.save() + self.client.search_engine.index_mail(bounced_mail) + + not_bounced_mail = MailBuilder( + ).with_tags(['important']).with_to('this_mail_was_not@bounced.com').build_input_mail() + self.client.add_mail_to_inbox(not_bounced_mail) + + d = self.get_contacts(query='this') + + def _assert(contacts): + self.assertNotIn('this_mail_was_bounced@domain.com', contacts) + self.assertIn('this_mail_was_not@bounced.com', contacts) + d.addCallback(_assert) + return d + + def _bounced_mail_hdoc_content(self): + hdoc_file = os.path.join(os.path.dirname(__file__), '..', 'unit', 'fixtures', 'bounced_mail_hdoc.json') + with open(hdoc_file) as f: + hdoc = json.loads(f.read()) + return hdoc -- cgit v1.2.3