Exemple #1
0
 def __init__(self, account, soledad_querier, search_engine):
     self.account = account
     self.querier = soledad_querier
     self.search_engine = search_engine
     for mailbox_name in account.mailboxes:
         MailboxIndexerListener.listen(self.account, mailbox_name,
                                       soledad_querier)
    def test_add_itself_to_mailbox_listeners(self):
        self.account.mailboxes = ['INBOX']
        mailbox = mock()
        when(self.account).getMailbox('INBOX').thenReturn(mailbox)
        mailbox.listeners = set()
        when(mailbox).addListener = lambda x: mailbox.listeners.add(x)

        self.assertNotIn(MailboxIndexerListener('INBOX', self.querier), mailbox.listeners)

        MailboxIndexerListener.listen(self.account, 'INBOX', self.querier)

        self.assertIn(MailboxIndexerListener('INBOX', self.querier), mailbox.listeners)
    def test_add_itself_to_mailbox_listeners(self):
        self.account.mailboxes = ['INBOX']
        mailbox = mock()
        when(self.account).get_collection_by_mailbox('INBOX').thenReturn(mailbox)
        mailbox.listeners = set()
        when(mailbox).addListener = lambda x: mailbox.listeners.add(x)

        self.assertNotIn(MailboxIndexerListener('INBOX', self.mail_store, mock()), mailbox.listeners)

        MailboxIndexerListener.listen(self.account, 'INBOX', self.mail_store, mock())

        self.assertIn(MailboxIndexerListener('INBOX', self.mail_store, mock()), mailbox.listeners)
 def _create_or_get(self, mailbox_name):
     mailbox_name = mailbox_name.upper()
     # if mailbox_name not in self.account.mailboxes:
     if mailbox_name not in (yield self.account.account.list_all_mailbox_names()):
         try:
             yield self.account.addMailbox(mailbox_name)
         except MailboxCollision:
             pass
             # It means that it is already created. FIXME Why list_all fails to tell?
     yield MailboxIndexerListener.listen(self.account, mailbox_name, self.querier)
     defer.returnValue(Mailbox.create(mailbox_name, self.querier, self.search_engine))
    def test_message_collection(self):
        # given
        mbx = yield self.account.getMailbox('INBOX')
        input_mail = MailBuilder().build_input_mail()

        # when
        yield MailboxIndexerListener.listen(self.account, 'INBOX', self.mail_store, self.search_engine)
        yield mbx.addMessage(input_mail.raw, [], notify_just_mdoc=False)

        # then
        yield self.wait_in_reactor()  # event handlers are called async, wait for it

        mails, mail_count = self.search_engine.search('in:all')
        self.assertEqual(1, mail_count)
        self.assertEqual(1, len(mails))
Exemple #6
0
    def test_message_collection(self):
        # given
        mail_collection = yield self.account.get_collection_by_mailbox('INBOX')
        input_mail = MailBuilder().build_input_mail()

        # when
        yield MailboxIndexerListener.listen(self.account, 'INBOX',
                                            self.mail_store,
                                            self.search_engine)
        yield mail_collection.add_msg(input_mail.raw)

        # then
        yield self.wait_in_reactor(
        )  # event handlers are called async, wait for it

        mails, mail_count = self.search_engine.search('in:all')
        self.assertEqual(1, mail_count)
        self.assertEqual(1, len(mails))
Exemple #7
0
    def test_message_collection(self):
        # given
        MailboxIndexerListener.SEARCH_ENGINE = self.search_engine
        mbx = yield self.account.getMailbox('INBOX')
        input_mail = MailBuilder().build_input_mail()

        # when
        yield MailboxIndexerListener.listen(self.account, 'INBOX',
                                            self.mail_store)
        yield mbx.addMessage(input_mail.raw, [], notify_just_mdoc=False)

        # then
        yield self.wait_in_reactor(
        )  # event handlers are called async, wait for it

        mails, mail_count = self.search_engine.search('in:all')
        self.assertEqual(1, mail_count)
        self.assertEqual(1, len(mails))
    def test_message_collection(self):
        # given
        mail_collection = yield self.app_test_client.account.get_collection_by_mailbox('INBOX')
        input_mail = MailBuilder().build_input_mail()

        # when
        yield MailboxIndexerListener.listen(
            self.app_test_client.account,
            'INBOX',
            self.app_test_client.mail_store,
            self.app_test_client.search_engine)
        yield mail_collection.add_msg(input_mail.raw)

        # then
        yield self.wait_in_reactor()  # event handlers are called async, wait for it

        mails, mail_count = self.app_test_client.search_engine.search('in:all')
        self.assertEqual(1, mail_count)
        self.assertEqual(1, len(mails))
 def _create_or_get(self, mailbox_name):
     mailbox_name = mailbox_name.upper()
     if mailbox_name not in self.account.mailboxes:
         self.account.addMailbox(mailbox_name)
     MailboxIndexerListener.listen(self.account, mailbox_name, self.querier)
     return Mailbox.create(mailbox_name, self.querier, self.search_engine)
 def __init__(self, account, soledad_querier, search_engine):
     self.account = account
     self.querier = soledad_querier
     self.search_engine = search_engine
     for mailbox_name in account.mailboxes:
         MailboxIndexerListener.listen(self.account, mailbox_name, soledad_querier)
 def _index_mailboxes(self, mailboxes):
     for mailbox_name in mailboxes:
         yield MailboxIndexerListener.listen(self.account, mailbox_name, self.querier)
Exemple #12
0
 def _create_or_get(self, mailbox_name):
     mailbox_name = mailbox_name.upper()
     if mailbox_name not in self.account.mailboxes:
         self.account.addMailbox(mailbox_name)
     MailboxIndexerListener.listen(self.account, mailbox_name, self.querier)
     return Mailbox.create(mailbox_name, self.querier, self.search_engine)
Exemple #13
0
 def __init__(self, account, soledad_querier):
     self.account = account
     self.querier = soledad_querier
     for mailbox_name in account.mailboxes:
         MailboxIndexerListener.listen(self.account, mailbox_name,
                                       soledad_querier)
 def __init__(self, account, soledad_querier):
     self.account = account
     self.querier = soledad_querier
     for mailbox_name in account.mailboxes:
         MailboxIndexerListener.listen(self.account, mailbox_name, soledad_querier)