Ejemplo n.º 1
0
def test_contact_update(config, message, db):
    update_contacts(db.session, ACCOUNT_ID, message)
    assert len(message.contacts) == 4
    to_contacts = [assoc.contact for assoc in message.contacts
                   if assoc.field == 'to_addr']
    assert len(to_contacts) == 1
    c = to_contacts[0]
    messages_to = [assoc.message for assoc in c.message_associations
                   if assoc.field == 'to_addr']
    assert len(messages_to) == 1
Ejemplo n.º 2
0
def create_gmail_message(db_session, log, acct, folder, msg):
    """ Gmail-specific message creation logic. """

    new_uid = account.create_imap_message(db_session, log, acct, folder, msg)

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

        update_contacts(db_session, acct.id, new_uid.message)
        return new_uid
Ejemplo n.º 3
0
Archivo: gmail.py Proyecto: caitp/inbox
def create_gmail_message(db_session, log, acct, folder, msg):
    """ Gmail-specific message creation logic. """

    new_uid = account.create_imap_message(db_session, log, acct, folder, msg)

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

        update_contacts(db_session, acct.id, new_uid.message)
        return new_uid
Ejemplo n.º 4
0
def rerank_contacts():
    with session_scope() as db_session:
        # Delete existing signals.
        signals = db_session.query(SearchSignal).all()
        for signal in signals:
            db_session.delete(signal)
        db_session.commit()
        messages = db_session.query(Message).all()
        for message in messages:
            account_id = message.namespace.account_id
            update_contacts(db_session, account_id, message)

        db_session.commit()
Ejemplo n.º 5
0
def test_contact_update(config, message, db):
    update_contacts(db.session, ACCOUNT_ID, message)
    assert len(message.contacts) == 4
    to_contacts = [
        assoc.contact for assoc in message.contacts if assoc.field == 'to_addr'
    ]
    assert len(to_contacts) == 1
    c = to_contacts[0]
    messages_to = [
        assoc.message for assoc in c.message_associations
        if assoc.field == 'to_addr'
    ]
    assert len(messages_to) == 1
Ejemplo n.º 6
0
def test_scoring(config, message, db):
    for _ in range(10):
        # Pretend to process a number of messages.
        update_contacts(db.session, 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
Ejemplo n.º 7
0
def test_scoring(config, message, db):
    for _ in range(10):
        # Pretend to process a number of messages.
        update_contacts(db.session, 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
Ejemplo n.º 8
0
def test_canonicalization(config, gmail_message, db):
    # STOPSHIP(emfree) doesn't actually test anything
    update_contacts(db.session, ACCOUNT_ID, gmail_message)
    contacts = db.session.query(Contact).filter(Contact.name == 'Somebody')
    assert contacts.count() == 1
Ejemplo n.º 9
0
def test_canonicalization(config, gmail_message, db):
    # STOPSHIP(emfree) doesn't actually test anything
    update_contacts(db.session, ACCOUNT_ID, gmail_message)
    contacts = db.session.query(Contact).filter(Contact.name == 'Somebody')
    assert contacts.count() == 1