Exemple #1
0
def test_event_rr():
    event = Event(event_dt_rr, **event_kwargs)
    assert event.recur is True
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event ⟳'
    assert event.long() == u'09:30-10:30 09.04.2014: An Event\nRepeat: FREQ=DAILY;COUNT=10'
    event = Event(event_d_rr, **event_kwargs)
    assert event.recur is True
    assert event.compact(datetime.date(2014, 4, 9)) == u'Another Event ⟳'
    assert event.long() == u'09.04.2014: Another Event\nRepeat: FREQ=DAILY;COUNT=10'
Exemple #2
0
def test_event_rr():
    event = Event(event_dt_rr, **event_kwargs)
    assert event.recur is True
    assert event.compact(datetime.date(2014, 4,
                                       9)) == u'09:30-10:30: An Event ⟳'
    assert event.long(
    ) == u'09:30-10:30 09.04.2014: An Event\nRepeat: FREQ=DAILY;COUNT=10'
    event = Event(event_d_rr, **event_kwargs)
    assert event.recur is True
    assert event.compact(datetime.date(2014, 4, 9)) == u'Another Event ⟳'
    assert event.long(
    ) == u'09.04.2014: Another Event\nRepeat: FREQ=DAILY;COUNT=10'
Exemple #3
0
    def __init__(self, collection, conf, date_list, location=None, repeat=None):
        try:
            event = aux.construct_event(
                date_list,
                location=location,
                repeat=repeat,
                **conf['locale'])
        except FatalError:
            sys.exit(1)
        event = Event(event,
                      collection.default_calendar_name,
                      locale=conf['locale'],
                      )

        try:
            collection.new(event)
        except ReadOnlyCalendarError:
            logger.fatal('ERROR: Cannot modify calendar "{}" as it is '
                         'read-only'.format(collection.default_calendar_name))
            sys.exit(1)
        if conf['default']['print_new'] == 'event':
            print(event.long())
        elif conf['default']['print_new'] == 'path':
            path = collection._calnames[event.calendar].path + event.href
            print(path.encode(conf['locale']['encoding']))
Exemple #4
0
def test_dt_two_tz():
    event = Event(event_dt_two_tz, **event_kwargs)
    assert normalize_component(cal_dt_two_tz) == normalize_component(event.raw)

    # local (Berlin) time!
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-16:30: An Event'
    assert event.long() == u'09:30-16:30 09.04.2014: An Event'
Exemple #5
0
def test_dt_two_tz():
    event = Event(event_dt_two_tz, **event_kwargs)
    assert normalize_component(cal_dt_two_tz) == normalize_component(event.raw)

    # local (Berlin) time!
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-16:30: An Event'
    assert event.long() == u'09:30-16:30 09.04.2014: An Event'
Exemple #6
0
    def __init__(self, collection, conf, date_list, location=None, repeat=None):
        try:
            event = aux.construct_event(
                date_list,
                location=location,
                repeat=repeat,
                **conf['locale'])
        except FatalError:
            sys.exit(1)
        event = Event(event,
                      collection.default_calendar_name,
                      locale=conf['locale'],
                      )

        try:
            collection.new(event)
        except ReadOnlyCalendarError:
            logger.fatal('ERROR: Cannot modify calendar "{}" as it is '
                         'read-only'.format(collection.default_calendar_name))
            sys.exit(1)
        if conf['default']['print_new'] == 'event':
            echo(event.long())
        elif conf['default']['print_new'] == 'path':
            path = collection._calnames[event.calendar].path + event.href
            echo(path.encode(conf['locale']['encoding']))
Exemple #7
0
def test_raw_dt():
    event = Event(event_dt, **event_kwargs)
    assert normalize_component(event.raw) == normalize_component(cal_dt)
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'

    event = Event(event_dt, unicode_symbols=False, **event_kwargs)
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'
    assert event.long() == u'09:30-10:30 09.04.2014: An Event'
    assert event.recur is False
Exemple #8
0
def test_event_no_dst():
    """test the creation of a corect VTIMEZONE for timezones with no dst"""
    bogota_locale = locale.copy()
    bogota_locale['local_timezone'] = bogota
    bogota_locale['default_timezone'] = bogota

    event = Event(event_no_dst, calendar='foobar', locale=bogota_locale)
    assert event.raw.split('\r\n') == cal_no_dst
    assert event.long() == u'09:30-10:30 09.04.2014: An Event'
Exemple #9
0
def test_raw_dt():
    event = Event(event_dt, **event_kwargs)
    assert normalize_component(event.raw) == normalize_component(cal_dt)
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'

    event = Event(event_dt, unicode_symbols=False, **event_kwargs)
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'
    assert event.long() == u'09:30-10:30 09.04.2014: An Event'
    assert event.recur is False
Exemple #10
0
def test_event_no_dst():
    """test the creation of a corect VTIMEZONE for timezones with no dst"""
    bogota_locale = locale.copy()
    bogota_locale['local_timezone'] = bogota
    bogota_locale['default_timezone'] = bogota

    event = Event(event_no_dst, calendar='foobar', locale=bogota_locale)
    assert event.raw.split('\r\n') == cal_no_dst
    assert event.long() == u'09:30-10:30 09.04.2014: An Event'
Exemple #11
0
def test_event_d_long():
    event = Event(event_d_long, **event_kwargs)
    with pytest.raises(ValueError):
        event.compact(datetime.date(2014, 4, 8))
    assert event.compact(datetime.date(2014, 4, 9)) == u'↦ Another Event'
    assert event.compact(datetime.date(2014, 4, 10)) == u'↔ Another Event'
    assert event.compact(datetime.date(2014, 4, 11)) == u'⇥ Another Event'
    with pytest.raises(ValueError):
        event.compact(datetime.date(2014, 4, 12))
    assert event.long() == u'09.04. - 11.04.2014: Another Event'
Exemple #12
0
def test_event_d_long():
    event = Event(event_d_long, **event_kwargs)
    with pytest.raises(ValueError):
        event.compact(datetime.date(2014, 4, 8))
    assert event.compact(datetime.date(2014, 4, 9)) == u'↦ Another Event'
    assert event.compact(datetime.date(2014, 4, 10)) == u'↔ Another Event'
    assert event.compact(datetime.date(2014, 4, 11)) == u'⇥ Another Event'
    with pytest.raises(ValueError):
        event.compact(datetime.date(2014, 4, 12))
    assert event.long() == u'09.04. - 11.04.2014: Another Event'
Exemple #13
0
def test_event_dt_long():
    event = Event(event_dt_long, **event_kwargs)
    with pytest.raises(ValueError):
        event.compact(datetime.date(2014, 4, 8))
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30→ : An Event'
    # FIXME ugly! replace with one arrow
    assert event.compact(datetime.date(2014, 4, 10)) == u'→ → : An Event'
    assert event.compact(datetime.date(2014, 4, 12)) == u'→ 10:30: An Event'
    with pytest.raises(ValueError):
        event.compact(datetime.date(2014, 4, 13))
    assert event.long() == u'09.04.2014 09:30 - 12.04.2014 10:30: An Event'
Exemple #14
0
def test_event_dt_long():
    event = Event(event_dt_long, **event_kwargs)
    with pytest.raises(ValueError):
        event.compact(datetime.date(2014, 4, 8))
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30→ : An Event'
    # FIXME ugly! replace with one arrow
    assert event.compact(datetime.date(2014, 4, 10)) == u'→ → : An Event'
    assert event.compact(datetime.date(2014, 4, 12)) == u'→ 10:30: An Event'
    with pytest.raises(ValueError):
        event.compact(datetime.date(2014, 4, 13))
    assert event.long() == u'09.04.2014 09:30 - 12.04.2014 10:30: An Event'
Exemple #15
0
def test_dt_two_tz():
    event = Event(event_dt_two_tz, **event_kwargs)
    assert '\r\n'.join(cal_dt_two_tz[:3]) in event.raw
    assert '\r\n'.join(cal_dt_two_tz[5:11]) in event.raw  # cet
    assert '\r\n'.join(cal_dt_two_tz[11:18]) in event.raw  # cest
    assert '\r\n'.join(cal_dt_two_tz[21:27]) in event.raw  # est
    assert '\r\n'.join(cal_dt_two_tz[27:34]) in event.raw  # edt
    assert '\r\n'.join(cal_dt_two_tz[35:]) in event.raw  # edt

    # local (Berlin) time!
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-16:30: An Event'
    assert event.long() == u'09:30-16:30 09.04.2014: An Event'
Exemple #16
0
def test_raw_dt():
    event = Event(event_dt, **event_kwargs)
    # timezone components might be ordered differently on different runs
    assert cal_dt[:3] == event.raw.split('\r\n')[:3]
    assert cal_dt[18:] == event.raw.split('\r\n')[18:]
    assert '\r\n'.join(cal_dt_cet) in event.raw
    assert '\r\n'.join(cal_dt_cest) in event.raw
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'
    event = Event(event_dt, unicode_symbols=False, **event_kwargs)
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'
    assert event.long() == u'09:30-10:30 09.04.2014: An Event'
    assert event.recur is False
Exemple #17
0
def test_event_dt_duration():
    """event has no end, but duration"""
    event = Event(event_dt_duration, **event_kwargs)
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'
    assert event.end == berlin.localize(datetime.datetime(2014, 4, 9, 10, 30))
    assert event.long() == u'09:30-10:30 09.04.2014: An Event'
Exemple #18
0
def test_event_dt_no_tz():
    """start and end time of no timezone"""
    event = Event(event_dt_no_tz, **event_kwargs)
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'
    assert event.long() == u'09:30-10:30 09.04.2014: An Event'
Exemple #19
0
def test_event_dt_no_tz():
    """start and end time of no timezone"""
    event = Event(event_dt_no_tz, **event_kwargs)
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'
    assert event.long() == u'09:30-10:30 09.04.2014: An Event'
Exemple #20
0
def test_event_dt_duration():
    """event has no end, but duration"""
    event = Event(event_dt_duration, **event_kwargs)
    assert event.compact(datetime.date(2014, 4, 9)) == u'09:30-10:30: An Event'
    assert event.end == berlin.localize(datetime.datetime(2014, 4, 9, 10, 30))
    assert event.long() == u'09:30-10:30 09.04.2014: An Event'
Exemple #21
0
def test_raw_d():
    event = Event(event_d, **event_kwargs)
    assert event.raw.split('\r\n') == cal_d
    assert event.compact(datetime.date(2014, 4, 9)) == u'Another Event'
    assert event.long() == u'09.04.2014: Another Event'
Exemple #22
0
def test_raw_d():
    event = Event(event_d, **event_kwargs)
    assert event.raw.split('\r\n') == cal_d
    assert event.compact(datetime.date(2014, 4, 9)) == u'Another Event'
    assert event.long() == u'09.04.2014: Another Event'