Пример #1
0
def test_format_one_day_time_range():
    c = vobject.iCalendar()
    e = c.add('vevent')
    e.add('summary').value = "This is a note"
    start = e.add('dtstart')
    start.value = datetime.datetime(2009, 11, 26, 9, 5, tzinfo = tz.local)
    end = e.add('dtend')
    end.value = datetime.datetime(2009, 11, 26, 13, 25, tzinfo = tz.local)
    output = StringIO()
    f = OrgTreeFormatter(output, ConfigParser(), None)
    text = f.format_event(e)
    assert text == '** This is a note\n   <2009-11-26 Thu 09:05-13:25>\n', text
    return
Пример #2
0
def test_format_allday():
    c = vobject.iCalendar()
    e = c.add('vevent')
    e.add('summary').value = "This is a note"
    start = e.add('dtstart')
    start.value = datetime.date(2009, 11, 6)
    end = e.add('dtend')
    end.value = datetime.date(2009, 11, 6)
    output = StringIO()
    f = OrgTreeFormatter(output, ConfigParser(), None)
    text = f.format_event(e)
    assert text == '** This is a note\n   <2009-11-06 Fri>\n', text
    return
Пример #3
0
def test_format_unicode():
    c = vobject.iCalendar()
    e = c.add('vevent')
    e.add('summary').value = "Unicode event"
    start = e.add('dtstart')
    start.value = datetime.date(2009, 11, 6)
    end = e.add('dtend')
    end.value = datetime.date(2009, 11, 6)
    e.add('description').value = u'This is the description. It has “unicode quotes.”'
    output = StringIO()
    config = ConfigParser()
    f = OrgTreeFormatter(output, config, None)
    class FauxCalendar(object):
        title = 'Title'
    f.start_calendar(FauxCalendar())
    text = f.format_event(e)
    assert text == u'** Unicode event\n   <2009-11-06 Fri>\n   - This is the description. It has “unicode quotes.”\n', text
    return
Пример #4
0
def test_format_with_calendar_title():
    c = vobject.iCalendar()
    e = c.add('vevent')
    e.add('summary').value = "This is a note"
    start = e.add('dtstart')
    start.value = datetime.date(2009, 11, 6)
    end = e.add('dtend')
    end.value = datetime.date(2009, 11, 6)
    output = StringIO()
    f = OrgTreeFormatter(output, ConfigParser(), None)
    class FauxCalendar(object):
        title = 'Title'
    f.start_calendar(FauxCalendar())
    f.add_event(e)
    text = output.getvalue()
    assert text == '# -*- coding: utf-8 -*-\n* Title\n  :CATEGORY: Title\n** This is a note\n   <2009-11-06 Fri>\n'
    return
Пример #5
0
def test_format_with_description():
    c = vobject.iCalendar()
    e = c.add('vevent')
    e.add('summary').value = "This is a note"
    e.add('description').value = "This is more detail\non two lines"
    start = e.add('dtstart')
    start.value = datetime.date(2009, 11, 6)
    end = e.add('dtend')
    end.value = datetime.date(2009, 11, 6)
    output = StringIO()
    f = OrgTreeFormatter(output, ConfigParser(), None)
    class FauxCalendar(object):
        title = 'Title'
    f.start_calendar(FauxCalendar())
    f.add_event(e)
    text = output.getvalue()
    expected = '# -*- coding: utf-8 -*-\n* Title\n  :CATEGORY: Title\n** This is a note\n   <2009-11-06 Fri>\n   - This is more detail\n     on two lines\n'
    print repr(expected)
    print repr(text)
    assert text == expected
    return