Esempio n. 1
0
def test_send_syncback(db, config, message):
    from inbox.server.sendmail.base import send, recipients
    from inbox.server.models.tables.imap import ImapAccount

    account = db.session.query(ImapAccount).get(ACCOUNT_ID)
    to, subject, body = message
    attachments = None
    cc = '*****@*****.**'
    bcc = None

    send(account, recipients(to, cc, bcc), subject, body, attachments)

    with crispin_client(account.id, account.provider) as c:
        # Ensure the sent email message is present in the test account,
        # in both the Inbox and Sent folders:
        criteria = ['NOT DELETED', 'SUBJECT "{0}"'.format(subject)]

        c.select_folder(account.inbox_folder.name, lambda x, y: None)
        inbox_uids = c.conn.search(criteria)
        assert inbox_uids, 'Message missing from Inbox'

        #c.delete_messages(inbox_uids)

        c.select_folder(account.sent_folder.name, lambda x, y: None)
        sent_uids = c.conn.search(criteria)
        assert sent_uids, 'Message missing from Sent'
Esempio n. 2
0
File: api.py Progetto: jre21/inbox
    def send_mail(self, recipients, subject, body, attachments=None):
        """ Sends a message with the given objects """
        account = self.namespace.account
        assert account is not None, "Can't send mail with this namespace"

        if type(recipients) != list:
            recipients = [recipients]

        send(account, recipients, subject, body, attachments)

        return 'OK'
Esempio n. 3
0
def test_send_reconcile(db, config, message, sync_client):
    from inbox.server.models.tables.base import Message, SpoolMessage
    from inbox.server.models.tables.imap import ImapAccount
    from inbox.server.sendmail.base import send, recipients

    to, subject, body = message
    attachment = None
    cc = '*****@*****.**'
    bcc = None

    # Create email message, store a local copy + send it:
    account = db.sesson.query(ImapAccount).get(ACCOUNT_ID)
    send(account, recipients(to, cc, bcc), subject, body, attachment)

    # Sync to verify reconciliation:
    synclet = Greenlet(sync_client.start_sync, ACCOUNT_ID)
    synclet.start()

    Greenlet.join(synclet, timeout=60)

    sync_client.stop_sync(ACCOUNT_ID)

    spool_messages = db.session.query(SpoolMessage).\
        filter_by(subject=subject).all()
    assert len(spool_messages) == 1, 'spool message missing'

    resolved_message_id = spool_messages[0].resolved_message_id
    assert resolved_message_id, 'spool message not reconciled'

    inbox_uid = spool_messages[0].inbox_uid
    thread_id = spool_messages[0].thread_id

    killall(synclet)

    reconciled_message = db.session.query(Message).get(resolved_message_id)
    assert reconciled_message.inbox_uid == inbox_uid,\
        'spool message, reconciled message have different inbox_uids'

    assert reconciled_message.thread_id == thread_id,\
        'spool message, reconciled message have different thread_ids'
def test_send_reconcile(db, config, message, sync_client):
    from inbox.server.models.tables.base import Message, SpoolMessage
    from inbox.server.models.tables.imap import ImapAccount
    from inbox.server.sendmail.base import send, recipients

    to, subject, body = message
    attachment = None
    cc = '*****@*****.**'
    bcc = None

    # Create email message, store a local copy + send it:
    account = db.sesson.query(ImapAccount).get(ACCOUNT_ID)
    send(account, recipients(to, cc, bcc), subject, body, attachment)

    # Sync to verify reconciliation:
    synclet = Greenlet(sync_client.start_sync, ACCOUNT_ID)
    synclet.start()

    Greenlet.join(synclet, timeout=60)

    sync_client.stop_sync(ACCOUNT_ID)

    spool_messages = db.session.query(SpoolMessage).\
        filter_by(subject=subject).all()
    assert len(spool_messages) == 1, 'spool message missing'

    resolved_message_id = spool_messages[0].resolved_message_id
    assert resolved_message_id, 'spool message not reconciled'

    inbox_uid = spool_messages[0].inbox_uid
    thread_id = spool_messages[0].thread_id

    killall(synclet)

    reconciled_message = db.session.query(Message).get(resolved_message_id)
    assert reconciled_message.inbox_uid == inbox_uid,\
        'spool message, reconciled message have different inbox_uids'

    assert reconciled_message.thread_id == thread_id,\
        'spool message, reconciled message have different thread_ids'
Esempio n. 5
0
def test_send(db, config, message, attach):
    from inbox.server.models.tables.base import (SpoolMessage, FolderItem,
                                                 Folder, Account)

    to, subject, body = message
    cc = '*****@*****.**'
    bcc = None
    attachfiles = create_attachment_metadata(attach)

    account = db.session.query(Account).get(ACCOUNT_ID)
    send(account, recipients(to, cc, bcc), subject, body, attachfiles)

    sent_messages = db.session.query(SpoolMessage).\
        filter_by(subject=subject).all()
    assert len(sent_messages) == 1, 'sent message missing'

    sent_thrid = sent_messages[0].thread_id

    sent_folder = db.session.query(Account).get(ACCOUNT_ID).sent_folder.name
    sent_items = db.session.query(FolderItem).join(Folder).filter(
        FolderItem.thread_id == sent_thrid,
        Folder.name == sent_folder).count()
    assert sent_items == 1, 'sent folder entry missing'