Exemple #1
0
def test_uses_local_updates(contacts_provider, contact_sync, db):
    """Test that non-conflicting local and remote updates to the same contact
    both get stored."""
    contacts_provider.supply_contact('Old Name', '*****@*****.**')
    contact_sync.provider_instance = contacts_provider
    contact_sync.poll()
    results = db.session.query(Contact).filter_by(source='local').all()
    # Fake a local contact update.
    results[-1].name = 'New Name'
    db.session.commit()

    contacts_provider.__init__()
    contacts_provider.supply_contact('Old Name', '*****@*****.**')
    contact_sync.provider_instance = contacts_provider
    contact_sync.poll()

    remote_results = db.session.query(Contact).filter_by(source='remote').all()
    names = [r.name for r in remote_results]
    assert 'New Name' in names
    email_addresses = [r.email_address for r in remote_results]
    assert '*****@*****.**' in email_addresses

    local_results = db.session.query(Contact).filter_by(source='local').all()
    names = [r.name for r in local_results]
    assert 'New Name' in names
    email_addresses = [r.email_address for r in local_results]
    assert '*****@*****.**' in email_addresses
Exemple #2
0
def test_deletes(contacts_provider, contact_sync, db):
    num_original_contacts = db.session.query(Contact).count()
    contacts_provider.supply_contact('Name', '*****@*****.**')
    contact_sync.provider = contacts_provider
    contact_sync.sync()
    num_current_contacts = db.session.query(Contact).count()
    assert num_current_contacts - num_original_contacts == 1

    contacts_provider.__init__()
    contacts_provider.supply_contact(None, None, deleted=True)
    contact_sync.sync()

    num_current_contacts = db.session.query(Contact).count()
    assert num_current_contacts == num_original_contacts
Exemple #3
0
def test_update_contact(contacts_provider, contact_sync, db):
    """Test that subsequent contact updates get stored."""
    contacts_provider.supply_contact('Old Name', '*****@*****.**')
    contact_sync.provider = contacts_provider
    contact_sync.sync()
    results = db.session.query(Contact).all()
    email_addresses = [r.email_address for r in results]
    assert '*****@*****.**' in email_addresses

    contacts_provider.__init__()
    contacts_provider.supply_contact('New Name', '*****@*****.**')
    contact_sync.sync()
    db.session.commit()

    results = db.session.query(Contact).all()
    names = [r.name for r in results]
    assert 'New Name' in names
    email_addresses = [r.email_address for r in results]
    assert '*****@*****.**' in email_addresses
Exemple #4
0
def test_update_contact(contacts_provider, contact_sync, db):
    """Test that subsequent contact updates get stored."""
    contacts_provider.supply_contact('Old Name', '*****@*****.**')
    contact_sync.provider_instance = contacts_provider
    contact_sync.poll()
    results = db.session.query(Contact).filter_by(source='remote').all()
    db.new_session()
    email_addresses = [r.email_address for r in results]
    assert '*****@*****.**' in email_addresses

    contacts_provider.__init__()
    contacts_provider.supply_contact('New Name', '*****@*****.**')
    contact_sync.poll()
    db.new_session()

    results = db.session.query(Contact).filter_by(source='remote').all()
    names = [r.name for r in results]
    assert 'New Name' in names
    email_addresses = [r.email_address for r in results]
    assert '*****@*****.**' in email_addresses