예제 #1
0
파일: crud.py 프로젝트: 0xcd03/inbox
def create_from_ics(namespace, db_session, ics_str):
    try:
        events = events_from_ics(namespace, ics_str)
    except MalformedEventError:
        return None
    db_session.add_all(events)
    db_session.commit()
    return events
예제 #2
0
def test_handle_missing_sequence_number(db, default_account):
    with open(absolute_path(FIXTURES + "event_without_sequence.ics")) as fd:
        data = fd.read()

    events = events_from_ics(default_account.namespace, default_account.emailed_events_calendar, data)
    events = events["invites"]
    assert len(events) == 1
    ev = events[0]
    assert ev.sequence_number == 0
예제 #3
0
def test_multiple_summaries(db, default_account):
    data = None
    with open(absolute_path(FIXTURES + "multiple_summaries.ics")) as fd:
        data = fd.read()

    events = events_from_ics(default_account.namespace, default_account.emailed_events_calendar, data)
    events = events["invites"]
    assert len(events) == 1
    assert events[0].title == "The Strokes - Is this it?"
예제 #4
0
파일: crud.py 프로젝트: dlitz/inbox
def create_from_ics(namespace, db_session, ics_str):
    account = db_session.query(Account).filter(
        Account.id == namespace.account_id).one()
    try:
        events = events_from_ics(namespace, account.default_calendar, ics_str)
    except MalformedEventError:
        return None
    db_session.add_all(events)
    db_session.commit()
    return events
예제 #5
0
def test_handle_missing_sequence_number(db, default_account):
    with open(absolute_path(FIXTURES + "event_without_sequence.ics")) as fd:
        data = fd.read()

    events = events_from_ics(default_account.namespace,
                             default_account.emailed_events_calendar, data)
    events = events["invites"]
    assert len(events) == 1
    ev = events[0]
    assert ev.sequence_number == 0
예제 #6
0
def test_multiple_summaries(db, default_account):
    data = None
    with open(absolute_path(FIXTURES + "multiple_summaries.ics")) as fd:
        data = fd.read()

    events = events_from_ics(default_account.namespace,
                             default_account.emailed_events_calendar, data)
    events = events["invites"]
    assert len(events) == 1
    assert events[0].title == "The Strokes - Is this it?"
def test_event_no_participants(db, default_account):
    data = None
    with open(absolute_path(FIXTURES + 'event_with_no_participants.ics')) as fd:
        data = fd.read()

    events = events_from_ics(default_account.namespace,
                             default_account.emailed_events_calendar, data)
    assert len(events) == 1, "There should be only one event in the test file"
    ev = events[0]
    assert len(ev.participants) == 0
예제 #8
0
파일: crud.py 프로젝트: olofster/inbox
def create_from_ics(namespace, db_session, ics_str):
    account = db_session.query(Account).filter(
        Account.id == namespace.account_id).one()
    try:
        events = events_from_ics(namespace, account.default_calendar, ics_str)
    except MalformedEventError:
        return None
    db_session.add_all(events)
    db_session.commit()
    return events
def test_iphone_through_exchange(db, default_account):
    data = None
    with open(absolute_path(FIXTURES + 'iphone_through_exchange.ics')) as fd:
        data = fd.read()

    events = events_from_ics(default_account.namespace,
                             default_account.emailed_events_calendar, data)
    assert len(events) == 1, "There should be only one event in the test file"

    ev = events[0]
    assert ev.start == arrow.get(2014, 12, 27, 15, 0)
    assert ev.end == arrow.get(2014, 12, 27, 16, 0)
예제 #10
0
def test_multiple_events(db, default_account):
    data = None
    with open(absolute_path(FIXTURES + 'multiple_events.ics')) as fd:
        data = fd.read()

    events = events_from_ics(default_account.namespace,
                             default_account.emailed_events_calendar, data)
    assert len(events) == 2
    ev0 = events[0]
    ev1 = events[1]
    assert len(ev0.participants) == 0
    assert len(ev1.participants) == 0

    assert ev1.start == arrow.get(2015, 03, 17, 0, 0)
예제 #11
0
def test_windows_tz_ical(db, default_account):
    data = None
    with open(absolute_path(FIXTURES + 'windows_event.ics')) as fd:
        data = fd.read()

    events = events_from_ics(default_account.namespace,
                             default_account.emailed_events_calendar, data)
    assert len(events) == 1, "There should be only one event in the test file"

    ev = events[0]
    assert ev.start == arrow.get(2015, 2, 20, 8, 30)
    assert ev.end == arrow.get(2015, 2, 20, 9, 0)
    assert ev.title == "Pommes"
    assert len(ev.participants) == 1
    assert ev.participants[0]['email'] == '*****@*****.**'
예제 #12
0
def test_icloud_allday_event(db, default_account):
    data = None
    with open(absolute_path(FIXTURES + 'icloud_oneday_event.ics')) as fd:
        data = fd.read()

    events = events_from_ics(default_account.namespace,
                             default_account.emailed_events_calendar, data)
    assert len(events) == 1, "There should be only one event in the test file"

    ev = events[0]
    assert ev.all_day is True
    assert ev.start == arrow.get(2015, 3, 16, 0, 0)
    assert ev.end == arrow.get(2015, 3, 17, 0, 0)

    assert len(ev.participants) == 2
    assert ev.participants[0]['email'] == '*****@*****.**'
예제 #13
0
def test_invalid_ical(db):
    with pytest.raises(MalformedEventError):
        account = db.session.query(Account).filter_by(id=ACCOUNT_ID).first()
        events_from_ics(account.namespace,
                        account.default_calendar, "asdf")
예제 #14
0
def test_invalid_ical(db, default_account):
    with pytest.raises(MalformedEventError):
        events_from_ics(default_account.namespace,
                        default_account.emailed_events_calendar, "asdf")
예제 #15
0
def test_invalid_ical(db, default_account):
    with pytest.raises(MalformedEventError):
        events_from_ics(default_account.namespace,
                        default_account.emailed_events_calendar, "asdf")
예제 #16
0
def test_invalid_ical(db):
    with pytest.raises(MalformedEventError):
        account = db.session.query(Account).filter_by(id=ACCOUNT_ID).first()
        events_from_ics(account.namespace, account.default_calendar, "asdf")