Example #1
0
def test_merge(config, event_sync):
    """Test the basic logic of the merge() function."""
    base = _default_event()
    remote = Event(account_id=ACCOUNT_ID,
                   subject='new subject',
                   body='new body',
                   location='new location',
                   busy=True,
                   locked=True,
                   reminders='',
                   recurrence='',
                   start=2,
                   end=3,
                   all_day=False,
                   time_zone=0,
                   source='remote')

    dest = _default_event()

    event_sync.merge(base, remote, dest)
    assert dest.subject == 'new subject'
    assert dest.body == 'new body'
    assert dest.location == 'new location'
    assert dest.busy
    assert dest.locked
    assert dest.start == 2
    assert dest.end == 3
Example #2
0
def test_merge_conflict(config, event_sync):
    """Test that merge() raises an error on conflict."""
    base = _default_event()

    remote = Event(account_id=ACCOUNT_ID,
                   subject='new subject',
                   body='new body',
                   location='new location',
                   busy=False,
                   locked=True,
                   reminders='',
                   recurrence='',
                   start=2,
                   end=3,
                   all_day=False,
                   time_zone=0,
                   source='remote')

    dest = Event(account_id=ACCOUNT_ID,
                 subject='subject2',
                 body='body2',
                 location='location2',
                 busy=False,
                 locked=False,
                 reminders='',
                 recurrence='',
                 start=0,
                 end=1,
                 all_day=False,
                 time_zone=0,
                 source='remote')

    with pytest.raises(MergeError):
        event_sync.merge(base, remote, dest)

    # Check no update in case of conflict
    assert dest.subject == 'subject2'
    assert dest.body == 'body2'
    assert dest.location == 'location2'