Ejemplo n.º 1
0
    def add_multiple_to_mailbox(self,
                                num,
                                mailbox='',
                                flags=[],
                                tags=[],
                                to='*****@*****.**',
                                cc='*****@*****.**',
                                bcc='*****@*****.**'):
        mails = []
        yield self.mail_store.add_mailbox(mailbox)
        for _ in range(num):
            builder = MailBuilder().with_status(flags).with_tags(tags).with_to(
                to).with_cc(cc).with_bcc(bcc)
            builder.with_body(str(random.random()))
            input_mail = builder.build_input_mail()
            mail = yield self.mail_store.add_mail(mailbox, input_mail.raw)
            if tags:
                mail.tags |= set(tags)
            if flags:
                for flag in flags:
                    mail.flags.add(flag)
            if tags or flags:
                yield self.mail_store.update_mail(mail)
            mails.append(mail)

        #     mbx = yield self.mailboxes._create_or_get(mailbox)
        #     mail = yield mbx.add(input_mail)
        #     mails.append(mail)
        #     mail.update_tags(input_mail.tags) if tags else None
        # self.search_engine.index_mails(mails) if tags else None

        defer.returnValue(mails)
    def add_multiple_to_mailbox(self, num, mailbox='', flags=[], tags=[], to='*****@*****.**', cc='*****@*****.**', bcc='*****@*****.**'):
        mails = []
        yield self.mail_store.add_mailbox(mailbox)
        for _ in range(num):
            builder = MailBuilder().with_status(flags).with_tags(tags).with_to(to).with_cc(cc).with_bcc(bcc)
            builder.with_body(str(random.random()))
            input_mail = builder.build_input_mail()
            mail = yield self.mail_store.add_mail(mailbox, input_mail.raw)
            if tags:
                mail.tags |= set(tags)
            if flags:
                for flag in flags:
                    mail.flags.add(flag)
            if tags or flags:
                yield self.mail_store.update_mail(mail)
            mails.append(mail)

        defer.returnValue(mails)
Ejemplo n.º 3
0
 def add_multiple_to_mailbox(self, num, mailbox='', flags=[], tags=[]):
     mails = []
     for _ in range(num):
         input_mail = MailBuilder().with_status(flags).with_tags(
             tags).build_input_mail()
         mail = self.mailboxes._create_or_get(mailbox).add(input_mail)
         mails.append(mail)
         mail.update_tags(input_mail.tags)
         self.search_engine.index_mail(mail)
     return mails
 def add_multiple_to_mailbox(self,
                             num,
                             mailbox='',
                             flags=[],
                             tags=[],
                             to='*****@*****.**',
                             cc='*****@*****.**',
                             bcc='*****@*****.**'):
     mails = []
     for _ in range(num):
         input_mail = MailBuilder().with_status(flags).with_tags(
             tags).with_to(to).with_cc(cc).with_bcc(bcc).build_input_mail()
         mail = self.mailboxes._create_or_get(mailbox).add(input_mail)
         mails.append(mail)
         mail.update_tags(input_mail.tags) if tags else None
     self.search_engine.index_mails(mails) if tags else None
     return mails