示例#1
0
def test_send_reply(db, config, action_queue, message, attach):
    from inbox.server.sendmail.base import create_draft, send_draft
    from inbox.server.models.tables.base import (SpoolMessage, Account, Thread,
                                                 FolderItem, Folder)

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

    thread = db.session.query(Thread).filter(
        Thread.namespace_id == NAMESPACE_ID, Thread.id == THREAD_ID).one()
    thread_public_id = thread.public_id

    draft = create_draft(db.session, account, to, subject, body, attachment,
                         cc, bcc, thread_public_id)
    send_draft(db.session, account, draft.public_id)

    message = db.session.query(SpoolMessage).filter(
        SpoolMessage.public_id == draft.public_id).one()

    # Check sent
    assert message.is_sent, 'message.is_sent not set to True'

    assert message.imapuids[0].folder.name == account.sent_folder.name, \
        'message.imapuid.folder is not set to sent folder'

    sent_thrid = message.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'

    assert message.inbox_uid, 'sent message.inbox_uid missing'

    expected_in_reply_to = TEST_MSG['message-id']
    in_reply_to = message.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 = message.references

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

    # Check not-draft
    assert not message.is_draft, 'message.is_draft still set to True'

    draft_thrid = message.thread_id
    draft_folder = db.session.query(Account).get(ACCOUNT_ID).drafts_folder.name
    draft_items = db.session.query(FolderItem).join(Folder).filter(
        FolderItem.thread_id == draft_thrid,
        Folder.name == draft_folder).count()
    assert draft_items == 0, 'draft folder entry still present'

    cleanup(account, subject)
示例#2
0
def test_send(db, config, action_queue, message, attach):
    from inbox.server.sendmail.base import create_draft, send_draft
    from inbox.server.models.tables.base import (SpoolMessage, Account,
                                                 FolderItem, Folder)

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

    draft = create_draft(db.session, account, to, subject, body,
                         attachment, cc, bcc)
    draft_id = draft.public_id

    send_draft(db.session, account, draft_id)

    message = db.session.query(SpoolMessage).filter(
        SpoolMessage.public_id == draft_id).one()

    # Check sent
    assert message.inbox_uid, 'sent message.inbox_uid missing'

    assert message.is_sent, 'message.is_sent not set to True'

    assert message.imapuids[0].folder.name == account.sent_folder.name, \
        'message.imapuid.folder is not set to sent folder'

    sent_thrid = message.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'

    # Check not-draft
    assert not message.is_draft, 'message.is_draft still set to True'

    draft_thrid = message.thread_id
    draft_folder = db.session.query(Account).get(ACCOUNT_ID).drafts_folder.name
    draft_items = db.session.query(FolderItem).join(Folder).filter(
        FolderItem.thread_id == draft_thrid,
        Folder.name == draft_folder).count()
    assert draft_items == 0, 'draft folder entry still present'

    cleanup(account, subject)
示例#3
0
def test_send(db, config, action_queue, message, attach):
    from inbox.server.sendmail.base import create_draft, send_draft
    from inbox.server.models.tables.base import (SpoolMessage, Account,
                                                 FolderItem, Folder)

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

    draft = create_draft(db.session, account, to, subject, body, attachment,
                         cc, bcc)
    draft_id = draft.public_id

    send_draft(db.session, account, draft_id)

    message = db.session.query(SpoolMessage).filter(
        SpoolMessage.public_id == draft_id).one()

    # Check sent
    assert message.inbox_uid, 'sent message.inbox_uid missing'

    assert message.is_sent, 'message.is_sent not set to True'

    assert message.imapuids[0].folder.name == account.sent_folder.name, \
        'message.imapuid.folder is not set to sent folder'

    sent_thrid = message.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'

    # Check not-draft
    assert not message.is_draft, 'message.is_draft still set to True'

    draft_thrid = message.thread_id
    draft_folder = db.session.query(Account).get(ACCOUNT_ID).drafts_folder.name
    draft_items = db.session.query(FolderItem).join(Folder).filter(
        FolderItem.thread_id == draft_thrid,
        Folder.name == draft_folder).count()
    assert draft_items == 0, 'draft folder entry still present'

    cleanup(account, subject)
示例#4
0
def test_send_reply(db, config, action_queue, message, attach):
    from inbox.server.sendmail.base import create_draft, send_draft
    from inbox.server.models.tables.base import (SpoolMessage, Account,
                                                 Thread, FolderItem,
                                                 Folder)

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

    thread = db.session.query(Thread).filter(
        Thread.namespace_id == NAMESPACE_ID,
        Thread.id == THREAD_ID).one()
    thread_public_id = thread.public_id

    draft = create_draft(db.session, account, to, subject, body, attachment,
                         cc, bcc, thread_public_id)
    send_draft(db.session, account, draft.public_id)

    message = db.session.query(SpoolMessage).filter(
        SpoolMessage.public_id == draft.public_id).one()

    # Check sent
    assert message.is_sent, 'message.is_sent not set to True'

    assert message.imapuids[0].folder.name == account.sent_folder.name, \
        'message.imapuid.folder is not set to sent folder'

    sent_thrid = message.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'

    assert message.inbox_uid, 'sent message.inbox_uid missing'

    expected_in_reply_to = TEST_MSG['message-id']
    in_reply_to = message.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 = message.references

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

    # Check not-draft
    assert not message.is_draft, 'message.is_draft still set to True'

    draft_thrid = message.thread_id
    draft_folder = db.session.query(Account).get(ACCOUNT_ID).drafts_folder.name
    draft_items = db.session.query(FolderItem).join(Folder).filter(
        FolderItem.thread_id == draft_thrid,
        Folder.name == draft_folder).count()
    assert draft_items == 0, 'draft folder entry still present'

    cleanup(account, subject)