コード例 #1
0
ファイル: account.py プロジェクト: jre21/inbox
def create_gmail_message(db_session, log, account, folder_name, msg):
    """ Gmail-specific message creation logic. """

    new_uid = create_imap_message(db_session, log, account, folder_name, msg)

    if new_uid:
        new_uid = add_gmail_attrs(db_session, log, new_uid, msg.flags,
                                  folder_name, msg.g_thrid, msg.g_msgid,
                                  msg.g_labels, msg.created)

        # Execute new-message hooks. We call this here and not in
        # create_message() so that hooks have access to thread data.
        default_hook_manager.execute_hooks(account.id, new_uid.message)
        return new_uid
コード例 #2
0
ファイル: test_hooks.py プロジェクト: jre21/inbox
def test_scoring(config, message, db):
    for _ in range(10):
        # Pretend to process a number of messages.
        default_hook_manager.execute_hooks(ACCOUNT_ID, message)
    # The expected scores here must be updated when the scoring function
    # changes.
    contact = db.session.query(Contact). \
        filter(Contact.email_address == '*****@*****.**').one()
    assert contact.score == 10
    contact = db.session.query(Contact). \
        filter(Contact.email_address == '*****@*****.**').one()
    assert contact.score == 19
    contact = db.session.query(Contact). \
        filter(Contact.email_address == '*****@*****.**').one()
    assert contact.score == 10
コード例 #3
0
ファイル: test_hooks.py プロジェクト: jre21/inbox
def test_contact_hooks(config, message, db):
    default_hook_manager.execute_hooks(ACCOUNT_ID, message)
    contacts = db.session.query(Contact)
    assert contacts.count() == 4
コード例 #4
0
ファイル: test_hooks.py プロジェクト: jre21/inbox
def test_canonicalization(config, gmail_message, db):
    default_hook_manager.execute_hooks(ACCOUNT_ID, gmail_message)
    contacts = db.session.query(Contact)
    assert contacts.count() == 1