コード例 #1
0
ファイル: vtimezone_test.py プロジェクト: 0mark/khal
def test_berlin_rdate():
    vberlin_std = b'\r\n'.join(
        [b'BEGIN:STANDARD',
         b'DTSTART;VALUE=DATE-TIME:20141026T020000',
         b'RDATE:20151025T020000,20161030T020000',
         b'TZNAME:CET',
         b'TZOFFSETFROM:+0200',
         b'TZOFFSETTO:+0100',
         b'END:STANDARD',
         ])

    vberlin_dst = b'\r\n'.join(
        [b'BEGIN:DAYLIGHT',
         b'DTSTART;VALUE=DATE-TIME:20150329T030000',
         b'RDATE:20160327T030000',
         b'TZNAME:CEST',
         b'TZOFFSETFROM:+0100',
         b'TZOFFSETTO:+0200',
         b'END:DAYLIGHT',
         ])

    vberlin = create_timezone(berlin, atime, btime).to_ical()
    assert b'TZID:Europe/Berlin' in vberlin
    assert vberlin_std in vberlin
    assert vberlin_dst in vberlin
コード例 #2
0
ファイル: vtimezone_test.py プロジェクト: ssiegel/khal
def test_berlin_rdate():
    vberlin_std = b'\r\n'.join([
        b'BEGIN:STANDARD',
        b'DTSTART;VALUE=DATE-TIME:20141026T020000',
        b'RDATE:20151025T020000,20161030T020000',
        b'TZNAME:CET',
        b'TZOFFSETFROM:+0200',
        b'TZOFFSETTO:+0100',
        b'END:STANDARD',
    ])

    vberlin_dst = b'\r\n'.join([
        b'BEGIN:DAYLIGHT',
        b'DTSTART;VALUE=DATE-TIME:20150329T030000',
        b'RDATE:20160327T030000',
        b'TZNAME:CEST',
        b'TZOFFSETFROM:+0100',
        b'TZOFFSETTO:+0200',
        b'END:DAYLIGHT',
    ])

    vberlin = create_timezone(berlin, atime, btime).to_ical()
    assert b'TZID:Europe/Berlin' in vberlin
    assert vberlin_std in vberlin
    assert vberlin_dst in vberlin
コード例 #3
0
ファイル: vtimezone_test.py プロジェクト: ssiegel/khal
def test_bogota():
    vbogota = [
        b'BEGIN:VTIMEZONE', b'TZID:America/Bogota', b'BEGIN:STANDARD',
        b'DTSTART;VALUE=DATE-TIME:19930403T230000', b'TZNAME:COT',
        b'TZOFFSETFROM:-0400', b'TZOFFSETTO:-0500', b'END:STANDARD',
        b'END:VTIMEZONE', b''
    ]
    assert create_timezone(bogota, atime,
                           atime).to_ical().split(b'\r\n') == vbogota
コード例 #4
0
ファイル: vtimezone_test.py プロジェクト: 0mark/khal
def test_bogota():
    vbogota = [b'BEGIN:VTIMEZONE',
               b'TZID:America/Bogota',
               b'BEGIN:STANDARD',
               b'DTSTART;VALUE=DATE-TIME:19930403T230000',
               b'TZNAME:COT',
               b'TZOFFSETFROM:-0400',
               b'TZOFFSETTO:-0500',
               b'END:STANDARD',
               b'END:VTIMEZONE',
               b'']
    assert create_timezone(bogota, atime, atime).to_ical().split(b'\r\n') == vbogota
コード例 #5
0
ファイル: vtimezone_test.py プロジェクト: semtle/khal
def test_bogota(pytz_version):
    vbogota = [
        b'BEGIN:VTIMEZONE', b'TZID:America/Bogota', b'BEGIN:STANDARD',
        b'DTSTART;VALUE=DATE-TIME:19930403T230000', b'TZNAME:COT',
        b'TZOFFSETFROM:-0400', b'TZOFFSETTO:-0500', b'END:STANDARD',
        b'END:VTIMEZONE', b''
    ]
    if pytz_version > (2017, 1):
        vbogota[4] = b'TZNAME:-05'
        vbogota.insert(4, b'RDATE:20380118T221407')

    assert create_timezone(bogota, atime,
                           atime).to_ical().split(b'\r\n') == vbogota
コード例 #6
0
ファイル: vtimezone_test.py プロジェクト: pdav/khal
def test_bogota(pytz_version):
    vbogota = [b'BEGIN:VTIMEZONE',
               b'TZID:America/Bogota',
               b'BEGIN:STANDARD',
               b'DTSTART;VALUE=DATE-TIME:19930403T230000',
               b'TZNAME:COT',
               b'TZOFFSETFROM:-0400',
               b'TZOFFSETTO:-0500',
               b'END:STANDARD',
               b'END:VTIMEZONE',
               b'']
    if pytz_version > (2017, 1):
        vbogota[4] = b'TZNAME:-05'
        vbogota.insert(4, b'RDATE:20380118T221407')

    assert create_timezone(bogota, atime, atime).to_ical().split(b'\r\n') == vbogota
コード例 #7
0
ファイル: event_test.py プロジェクト: pdav/khal
def test_create_timezone_static():
    gmt = pytz.timezone('Etc/GMT-8')
    assert create_timezone(gmt).to_ical().split() == [
        b'BEGIN:VTIMEZONE',
        b'TZID:Etc/GMT-8',
        b'BEGIN:STANDARD',
        b'DTSTART;VALUE=DATE-TIME:16010101T000000',
        b'RDATE:16010101T000000',
        b'TZNAME:Etc/GMT-8',
        b'TZOFFSETFROM:+0800',
        b'TZOFFSETTO:+0800',
        b'END:STANDARD',
        b'END:VTIMEZONE',
    ]
    event_dt = _get_text('event_dt_simple')
    start = GMTPLUS3.localize(dt.datetime(2014, 4, 9, 9, 30))
    end = GMTPLUS3.localize(dt.datetime(2014, 4, 9, 10, 30))
    event = Event.fromString(event_dt, **EVENT_KWARGS)
    event.update_start_end(start, end)
    with freeze_time('2016-1-1'):
        assert normalize_component(event.raw) == normalize_component(
            """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//PIMUTILS.ORG//NONSGML khal / icalendar //EN
BEGIN:VTIMEZONE
TZID:Etc/GMT+3
BEGIN:STANDARD
DTSTART;VALUE=DATE-TIME:16010101T000000
RDATE:16010101T000000
TZNAME:Etc/GMT+3
TZOFFSETFROM:-0300
TZOFFSETTO:-0300
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:An Event
DTSTART;TZID=Etc/GMT+3;VALUE=DATE-TIME:20140409T093000
DTEND;TZID=Etc/GMT+3;VALUE=DATE-TIME:20140409T103000
DTSTAMP;VALUE=DATE-TIME:20140401T234817Z
UID:V042MJ8B3SJNFXQOJL6P53OFMHJE8Z3VZWOU
END:VEVENT
END:VCALENDAR"""
        )
コード例 #8
0
def test_create_timezone_static():
    gmt = pytz.timezone('Etc/GMT-8')
    assert create_timezone(gmt).to_ical().split() == [
        b'BEGIN:VTIMEZONE',
        b'TZID:Etc/GMT-8',
        b'BEGIN:STANDARD',
        b'DTSTART;VALUE=DATE-TIME:16010101T000000',
        b'RDATE:16010101T000000',
        b'TZNAME:Etc/GMT-8',
        b'TZOFFSETFROM:+0800',
        b'TZOFFSETTO:+0800',
        b'END:STANDARD',
        b'END:VTIMEZONE',
    ]
    event_dt = _get_text('event_dt_simple')
    start = GMTPLUS3.localize(dt.datetime(2014, 4, 9, 9, 30))
    end = GMTPLUS3.localize(dt.datetime(2014, 4, 9, 10, 30))
    event = Event.fromString(event_dt, **EVENT_KWARGS)
    event.update_start_end(start, end)
    with freeze_time('2016-1-1'):
        assert normalize_component(event.raw) == normalize_component(
            """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//PIMUTILS.ORG//NONSGML khal / icalendar //EN
BEGIN:VTIMEZONE
TZID:Etc/GMT+3
BEGIN:STANDARD
DTSTART;VALUE=DATE-TIME:16010101T000000
RDATE:16010101T000000
TZNAME:Etc/GMT+3
TZOFFSETFROM:-0300
TZOFFSETTO:-0300
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:An Event
DTSTART;TZID=Etc/GMT+3;VALUE=DATE-TIME:20140409T093000
DTEND;TZID=Etc/GMT+3;VALUE=DATE-TIME:20140409T103000
DTSTAMP;VALUE=DATE-TIME:20140401T234817Z
UID:V042MJ8B3SJNFXQOJL6P53OFMHJE8Z3VZWOU
END:VEVENT
END:VCALENDAR"""
        )