Example #1
0
def test_no_change(db):
    local = default_event(db)
    local.participant_list = [
        {'email': '*****@*****.**',
         'status': 'noreply'},
        {'email': '*****@*****.**',
         'status': 'noreply'},
        {'email': '*****@*****.**',
         'status': 'noreply'}]
    remote = default_event(db)
    remote.participant_list = [
        {'email': '*****@*****.**',
         'status': 'noreply'},
        {'email': '*****@*****.**',
         'status': 'noreply'},
        {'email': '*****@*****.**',
         'status': 'noreply'}]
    new = default_event(db)
    new.participant_list = [
        {'email': '*****@*****.**',
         'status': 'noreply'},
        {'email': '*****@*****.**',
         'status': 'noreply'},
        {'email': '*****@*****.**',
         'status': 'noreply'}]

    local.merge_from(remote, new)
    remote.copy_from(local)

    assert len(local.participants) == 3
    assert len(new.participants) == 3
    assert len(remote.participants) == 3

    db.session.add_all([local, remote, new])
def test_multi_update(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db.session)
    base.participants = [{'email_address': "*****@*****.**", "status": "no"}]

    dest = default_event(db.session)
    dest.participants = [{
        'email_address': "*****@*****.**",
        "status": "no"
    }, {
        'email_address': "*****@*****.**",
        "status": "no"
    }]

    remote = default_event(db.session)
    remote.participants = [{
        'email_address': "*****@*****.**",
        "status": "yes"
    }]

    dest.merge_from(base, remote)
    assert len(dest.participants) == 2
    for p in dest.participants:
        if p['email_address'] == "*****@*****.**":
            assert p['status'] == "yes"
        if p['email_address'] == "*****@*****.**":
            assert p['status'] == "no"
def test_add_participant(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db.session)
    remote = default_event(db.session)
    remote.participants = [{'email_address': '*****@*****.**'}]

    dest = default_event(db.session)

    dest.merge_from(base, remote)
    assert len(dest.participants) == 1
def test_add_participant(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db.session)
    remote = default_event(db.session)
    remote.participants = [{'email_address': '*****@*****.**'}]

    dest = default_event(db.session)

    dest.merge_from(base, remote)
    assert len(dest.participants) == 1
Example #5
0
def test_add_participant(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db)
    participant = Participant(email_address="*****@*****.**")
    remote = default_event(db)
    remote.participants = [participant]

    dest = default_event(db)

    dest.merge_from(base, remote)
    assert len(dest.participants) == 1
def test_add_participant(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db)
    participant = Participant(email_address="*****@*****.**")
    remote = default_event(db)
    remote.participants = [participant]

    dest = default_event(db)

    dest.merge_from(base, remote)
    assert len(dest.participants) == 1
def test_update_participant_status2(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db.session)
    base.participants = [{'email_address':"*****@*****.**", "status": "no"}]

    dest = default_event(db.session)
    dest.participants = [{'email_address':"*****@*****.**", "status": "no"}]

    remote = default_event(db.session)
    remote.participants = [{'email_address':"*****@*****.**", "status": "yes"}]

    dest.merge_from(base, remote)
    assert len(dest.participants) == 1
    assert dest.participants[0]['status'] == 'yes'
def test_update_participant_status(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db.session)
    base.participants = [{'email_address': "*****@*****.**"}]

    dest = default_event(db.session)
    dest.participants = [{'email_address': "*****@*****.**"}]

    participant1 = {'email_address': "*****@*****.**", 'status': "yes"}
    remote = default_event(db.session)
    remote.participants = [participant1]

    dest.merge_from(base, remote)
    assert len(dest.participants) == 1
    assert dest.participants[0]['status'] == 'yes'
Example #9
0
def test_update_participant_status(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db)
    base.participants = [Participant(email_address="*****@*****.**")]

    dest = default_event(db)
    dest.participants = [Participant(email_address="*****@*****.**")]

    participant1 = Participant(email_address="*****@*****.**", status="yes")
    remote = default_event(db)
    remote.participants = [participant1]

    dest.merge_from(base, remote)
    assert len(dest.participants) == 1
    assert dest.participants[0].status == 'yes'
def test_update_participant_status(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db)
    base.participants = [Participant(email_address="*****@*****.**")]

    dest = default_event(db)
    dest.participants = [Participant(email_address="*****@*****.**")]

    participant1 = Participant(email_address="*****@*****.**",
                               status="yes")
    remote = default_event(db)
    remote.participants = [participant1]

    dest.merge_from(base, remote)
    assert len(dest.participants) == 1
    assert dest.participants[0].status == 'yes'
Example #11
0
def test_initial(db):
    remote = default_event(db.session)
    remote.participant_list = [{
        'email': '*****@*****.**',
        'status': 'noreply'
    }, {
        'email': '*****@*****.**',
        'status': 'noreply'
    }, {
        'email': '*****@*****.**',
        'status': 'noreply'
    }]

    local = Event(namespace_id=NAMESPACE_ID,
                  calendar=default_calendar(db.session),
                  provider_name='inbox',
                  raw_data='',
                  read_only=False,
                  all_day=False,
                  source='local')
    local.copy_from(remote)
    local.source = 'local'
    assert len(local.participants) == 3
    assert len(remote.participants) == 3
    db.session.add_all([local, remote])

    local.copy_from(remote)
    assert len(local.participants) == 3
    assert len(remote.participants) == 3
Example #12
0
def test_merge(db, config, event_sync):
    """Test the basic logic of the merge() function."""
    base = default_event(db)
    remote = default_event(db)
    remote.title = 'new title'
    remote.description = 'new description'
    remote.location = 'new location'

    dest = default_event(db)

    dest.merge_from(base, remote)
    assert dest.title == 'new title'
    assert dest.description == 'new description'
    assert dest.location == 'new location'
    assert dest.read_only is False
    assert dest.start == base.start
    assert dest.end == base.end
Example #13
0
def test_add_participant_remote(db):
    local = default_event(db.session)
    local.participant_list = [{
        'email': '*****@*****.**',
        'status': 'noreply'
    }, {
        'email': '*****@*****.**',
        'status': 'noreply'
    }, {
        'email': '*****@*****.**',
        'status': 'noreply'
    }]
    remote = default_event(db.session)
    remote.participant_list = [{
        'email': '*****@*****.**',
        'status': 'noreply'
    }, {
        'email': '*****@*****.**',
        'status': 'noreply'
    }, {
        'email': '*****@*****.**',
        'status': 'noreply'
    }]
    new = default_event(db.session)
    new.participant_list = [{
        'email': '*****@*****.**',
        'status': 'noreply'
    }, {
        'email': '*****@*****.**',
        'status': 'noreply'
    }, {
        'email': '*****@*****.**',
        'status': 'noreply'
    }, {
        'email': '*****@*****.**',
        'status': 'noreply'
    }]

    local.merge_from(remote, new)
    remote.copy_from(local)

    assert len(local.participants) == 4
    assert len(new.participants) == 4
    assert len(remote.participants) == 4

    db.session.add_all([local, remote, new])
Example #14
0
def test_merge(db, config, event_sync):
    """Test the basic logic of the merge() function."""
    base = default_event(db)
    remote = default_event(db)
    remote.title = 'new title'
    remote.description = 'new description'
    remote.location = 'new location'

    dest = default_event(db)

    dest.merge_from(base, remote)
    assert dest.title == 'new title'
    assert dest.description == 'new description'
    assert dest.location == 'new location'
    assert dest.read_only is False
    assert dest.start == base.start
    assert dest.end == base.end
def test_multi_update(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db.session)
    base.participants = [{'email_address':"*****@*****.**", "status": "no"}]

    dest = default_event(db.session)
    dest.participants = [{'email_address':"*****@*****.**", "status": "no"},
                         {'email_address':"*****@*****.**", "status": "no"}]

    remote = default_event(db.session)
    remote.participants = [{'email_address':"*****@*****.**", "status": "yes"}]

    dest.merge_from(base, remote)
    assert len(dest.participants) == 2
    for p in dest.participants:
        if p['email_address'] == "*****@*****.**":
            assert p['status'] == "yes"
        if p['email_address'] == "*****@*****.**":
            assert p['status'] == "no"
Example #16
0
def test_merge_conflict(db, config, event_sync):
    """Test that merge() raises an error on conflict."""
    base = default_event(db)

    remote = default_event(db)

    remote.title = 'new title'
    remote.description = 'new description'
    remote.location = 'new location'

    dest = default_event(db)
    dest.title = 'title2'
    dest.description = 'description2'
    dest.location = 'location2'

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

    # Check no update in case of conflict
    assert dest.title == 'title2'
    assert dest.description == 'description2'
    assert dest.location == 'location2'
Example #17
0
def test_merge_conflict(db, config, event_sync):
    """Test that merge() raises an error on conflict."""
    base = default_event(db)

    remote = default_event(db)

    remote.title = 'new title'
    remote.description = 'new description'
    remote.location = 'new location'

    dest = default_event(db)
    dest.title = 'title2'
    dest.description = 'description2'
    dest.location = 'location2'

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

    # Check no update in case of conflict
    assert dest.title == 'title2'
    assert dest.description == 'description2'
    assert dest.location == 'location2'
def test_multi_update(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db)
    base.participants = [Participant(email_address="*****@*****.**",
                                     status="no")]

    dest = default_event(db)
    dest.participants = [Participant(email_address="*****@*****.**",
                                     status="no"),
                         Participant(email_address="*****@*****.**",
                                     status="no")]

    participant1 = Participant(email_address="*****@*****.**",
                               status="yes")
    remote = default_event(db)
    remote.participants = [participant1]

    dest.merge_from(base, remote)
    assert len(dest.participants) == 2
    for p in dest.participants:
        if p.email_address == "*****@*****.**":
            assert p.status == "yes"
        if p.email_address == "*****@*****.**":
            assert p.status == "no"
Example #19
0
def test_multi_update(db, config):
    """Test the basic logic of the merge() function."""
    base = default_event(db)
    base.participants = [
        Participant(email_address="*****@*****.**", status="no")
    ]

    dest = default_event(db)
    dest.participants = [
        Participant(email_address="*****@*****.**", status="no"),
        Participant(email_address="*****@*****.**", status="no")
    ]

    participant1 = Participant(email_address="*****@*****.**", status="yes")
    remote = default_event(db)
    remote.participants = [participant1]

    dest.merge_from(base, remote)
    assert len(dest.participants) == 2
    for p in dest.participants:
        if p.email_address == "*****@*****.**":
            assert p.status == "yes"
        if p.email_address == "*****@*****.**":
            assert p.status == "no"
Example #20
0
def test_initial(db):
    remote = default_event(db)
    remote.participant_list = [
        {'email': '*****@*****.**',
         'status': 'noreply'},
        {'email': '*****@*****.**',
         'status': 'noreply'},
        {'email': '*****@*****.**',
         'status': 'noreply'}]

    local = Event(account_id=ACCOUNT_ID,
                  calendar=default_calendar(db),
                  provider_name='inbox', raw_data='',
                  read_only=False, all_day=False,
                  source='local')
    local.copy_from(remote)
    local.source = 'local'
    assert len(local.participants) == 3
    assert len(remote.participants) == 3
    db.session.add_all([local, remote])

    local.copy_from(remote)
    assert len(local.participants) == 3
    assert len(remote.participants) == 3