Skip to content

Commit

Permalink
Add tests for status and url
Browse files Browse the repository at this point in the history
  • Loading branch information
tresni committed Oct 30, 2021
1 parent d92a2eb commit 0edd8b9
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
5 changes: 3 additions & 2 deletions icalevents/icalparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def copy_to(self, new_start=None, uid=None):
ne.created = self.created
ne.last_modified = self.last_modified
ne.categories = self.categories
ne.status = self.status
ne.url = self.url

return ne
Expand Down Expand Up @@ -231,10 +232,10 @@ def create_event(component, tz=UTC):
event.categories = encoded_categories

if component.get("status"):
event.status = component.get("status")
event.status = encode(component.get("status"))

if component.get("url"):
event.url = component.get("url")
event.url = encode(component.get("url"))

return event

Expand Down
41 changes: 41 additions & 0 deletions test/test_data/status_and_url.ics
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions test/test_icalevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,17 @@ def test_transparent(self):

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)

0 comments on commit 0edd8b9

Please sign in to comment.