Merge pull request #92 from tresni/missing-status

Finalize support for STATUS/URL
pull/96/head
Martin Eigenmann 2021-11-07 18:02:52 +01:00 zatwierdzone przez GitHub
commit c368ad8ec4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 65 dodań i 0 usunięć

Wyświetl plik

@ -50,6 +50,8 @@ class Event:
self.attendee = None
self.organizer = None
self.categories = None
self.status = None
self.url = None
def time_left(self, time=None):
"""
@ -141,6 +143,8 @@ class Event:
ne.created = self.created
ne.last_modified = self.last_modified
ne.categories = self.categories
ne.status = self.status
ne.url = self.url
return ne
@ -227,6 +231,12 @@ def create_event(component, tz=UTC):
encoded_categories.append(encode(category))
event.categories = encoded_categories
if component.get("status"):
event.status = encode(component.get("status"))
if component.get("url"):
event.url = encode(component.get("url"))
return event

Wyświetl plik

@ -0,0 +1,41 @@
BEGIN:VCALENDAR
BEGIN:VTIMEZONE
TZID:Europe/Berlin
END:VTIMEZONE
BEGIN:VEVENT
DESCRIPTION:Event with Status and URL
SUMMARY:Tentative Event w/ Recurrance to test copy
STATUS:TENTATIVE
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
RRULE:FREQ=WEEKLY;BYDAY=TU
END:VEVENT
BEGIN:VEVENT
DESCRIPTION:Event with Status and URL
SUMMARY:Confirmed Event
STATUS:CONFIRMED
URL:https://example.com/
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
END:VEVENT
BEGIN:VEVENT
DESCRIPTION:Event with Status
SUMMARY:Cancelled Event
STATUS:CANCELLED
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
END:VEVENT
BEGIN:VEVENT
DESCRIPTION:Event with Status
SUMMARY:XPARAM Event
STATUS;X-SOMETHING=IGNOREME:CANCELLED
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
END:VEVENT
BEGIN:VEVENT
DESCRIPTION:Event without Status
SUMMARY:Event
DTSTART;VALUE=DATE:20181030
DTEND;VALUE=DATE:20181031
END:VEVENT
END:VCALENDAR

Wyświetl plik

@ -436,3 +436,17 @@ class ICalEventsTests(unittest.TestCase):
self.assertEqual(e1.transparent, True, "respect transparency")
self.assertEqual(e2.transparent, False, "respect opaqueness")
def test_status_and_url(self):
ical = "test/test_data/status_and_url.ics"
start = date(2018, 10, 30)
end = date(2018, 10, 31)
[ev1, ev2, ev3, ev4, ev5] = icalevents.events(file=ical, start=start, end=end)
self.assertEqual(ev1.status, "TENTATIVE")
self.assertEqual(ev1.url, None)
self.assertEqual(ev2.status, "CONFIRMED")
self.assertEqual(ev2.url, "https://example.com/")
self.assertEqual(ev3.status, "CANCELLED")
self.assertEqual(ev4.status, "CANCELLED")
self.assertEqual(ev5.status, None)