示例#1
0
def test_uses_local_updates(events_provider, event_sync, db):
    """Test that non-conflicting local and remote updates to the same event
    both get stored."""
    events_provider.supply_event('subj', '', 0, 1, False, False)
    event_sync.provider_instance = events_provider
    event_sync.poll()
    results = db.session.query(Event).filter_by(source='local').all()
    # Fake a local event update.
    results[-1].subject = 'New Subject'
    db.session.commit()

    events_provider.__init__()
    events_provider.supply_event('subj', 'newbody', 0, 1, False, False)
    event_sync.provider_instance = events_provider
    event_sync.poll()

    remote_results = db.session.query(Event).filter_by(source='remote').all()
    subjects = [r.subject for r in remote_results]
    assert 'New Subject' in subjects
    bodies = [r.body for r in remote_results]
    assert 'newbody' in bodies

    local_results = db.session.query(Event).filter_by(source='local').all()
    subjects = [r.subject for r in local_results]
    assert 'New Subject' in subjects
    bodies = [r.body for r in local_results]
    assert 'newbody' in bodies
示例#2
0
def test_uses_local_updates(events_provider, event_sync, db):
    """Test that non-conflicting local and remote updates to the same event
    both get stored."""
    events_provider.supply_event('subj', '', 0, 1, False, False)
    event_sync.provider_instance = events_provider
    event_sync.poll()
    results = db.session.query(Event).filter_by(source='local').all()
    # Fake a local event update.
    results[-1].subject = 'New Subject'
    db.session.commit()

    events_provider.__init__()
    events_provider.supply_event('subj', 'newbody', 0, 1, False, False)
    event_sync.provider_instance = events_provider
    event_sync.poll()

    remote_results = db.session.query(Event).filter_by(source='remote').all()
    subjects = [r.subject for r in remote_results]
    assert 'New Subject' in subjects
    bodies = [r.body for r in remote_results]
    assert 'newbody' in bodies

    local_results = db.session.query(Event).filter_by(source='local').all()
    subjects = [r.subject for r in local_results]
    assert 'New Subject' in subjects
    bodies = [r.body for r in local_results]
    assert 'newbody' in bodies
示例#3
0
def test_deletes(events_provider, event_sync, db):
    num_original_events = db.session.query(Event).count()
    events_provider.supply_event('subj', '', 0, 1, False, False)
    event_sync.provider_instance = events_provider
    event_sync.poll()
    num_current_events = db.session.query(Event).count()
    assert num_current_events - num_original_events == 2

    events_provider.__init__()
    events_provider.supply_event('subj', '', 0, 1, False, False, deleted=True)
    event_sync.poll()

    num_current_events = db.session.query(Event).count()
    assert num_current_events == num_original_events
示例#4
0
def test_deletes(events_provider, event_sync, db):
    num_original_events = db.session.query(Event).count()
    events_provider.supply_event('subj', '', 0, 1, False, False)
    event_sync.provider_instance = events_provider
    event_sync.poll()
    num_current_events = db.session.query(Event).count()
    assert num_current_events - num_original_events == 2

    events_provider.__init__()
    events_provider.supply_event('subj', '', 0, 1, False, False, deleted=True)
    event_sync.poll()

    num_current_events = db.session.query(Event).count()
    assert num_current_events == num_original_events
示例#5
0
def test_update_event(events_provider, event_sync, db):
    """Test that subsequent event updates get stored."""
    events_provider.supply_event('subj', '', 0, 1, False, False)
    event_sync.provider_instance = events_provider
    event_sync.poll()
    results = db.session.query(Event).filter_by(source='remote').all()
    db.new_session()
    subjects = [r.subject for r in results]
    assert 'subj' in subjects

    events_provider.__init__()
    events_provider.supply_event('newsubj', 'newbody', 0, 1, False, False)
    event_sync.poll()
    db.new_session()

    results = db.session.query(Event).filter_by(source='remote').all()
    subjs = [r.subject for r in results]
    assert 'newsubj' in subjs
    bodies = [r.body for r in results]
    assert 'newbody' in bodies
示例#6
0
def test_update_event(events_provider, event_sync, db):
    """Test that subsequent event updates get stored."""
    events_provider.supply_event('subj', '', 0, 1, False, False)
    event_sync.provider_instance = events_provider
    event_sync.poll()
    results = db.session.query(Event).filter_by(source='remote').all()
    db.new_session()
    subjects = [r.subject for r in results]
    assert 'subj' in subjects

    events_provider.__init__()
    events_provider.supply_event('newsubj', 'newbody', 0, 1, False, False)
    event_sync.poll()
    db.new_session()

    results = db.session.query(Event).filter_by(source='remote').all()
    subjs = [r.subject for r in results]
    assert 'newsubj' in subjs
    bodies = [r.body for r in results]
    assert 'newbody' in bodies