Exemple #1
0
def test_reply(db, config, message, attach):
    from inbox.server.models.tables.base import (SpoolMessage, FolderItem,
                                                 Folder, Account)

    to, subject, body = message
    attachfiles = create_attachment_metadata(attach)

    account = db.session.query(Account).get(ACCOUNT_ID)
    reply(NAMESPACE_ID, account, THREAD_ID, recipients(to, None, None),
          subject, body, attachfiles)

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

    expected_in_reply_to = TEST_MSG['message-id']
    in_reply_to = sent_messages[0].in_reply_to
    assert in_reply_to == expected_in_reply_to, 'incorrect in_reply_to header'

    separator = '\t'
    expected_references = TEST_MSG['references'] + separator +\
        TEST_MSG['message-id']
    references = sent_messages[0].references

    assert references.split() == expected_references.split(),\
        'incorrect references header'

    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'
Exemple #2
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'