Skip to content

Commit 0edd8b9

Browse files
committed
Add tests for status and url
1 parent d92a2eb commit 0edd8b9

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

icalevents/icalparser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def copy_to(self, new_start=None, uid=None):
143143
ne.created = self.created
144144
ne.last_modified = self.last_modified
145145
ne.categories = self.categories
146+
ne.status = self.status
146147
ne.url = self.url
147148

148149
return ne
@@ -231,10 +232,10 @@ def create_event(component, tz=UTC):
231232
event.categories = encoded_categories
232233

233234
if component.get("status"):
234-
event.status = component.get("status")
235+
event.status = encode(component.get("status"))
235236

236237
if component.get("url"):
237-
event.url = component.get("url")
238+
event.url = encode(component.get("url"))
238239

239240
return event
240241

test/test_data/status_and_url.ics

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
BEGIN:VCALENDAR
2+
BEGIN:VTIMEZONE
3+
TZID:Europe/Berlin
4+
END:VTIMEZONE
5+
BEGIN:VEVENT
6+
DESCRIPTION:Event with Status and URL
7+
SUMMARY:Tentative Event w/ Recurrance to test copy
8+
STATUS:TENTATIVE
9+
DTSTART;VALUE=DATE:20181030
10+
DTEND;VALUE=DATE:20181031
11+
RRULE:FREQ=WEEKLY;BYDAY=TU
12+
END:VEVENT
13+
BEGIN:VEVENT
14+
DESCRIPTION:Event with Status and URL
15+
SUMMARY:Confirmed Event
16+
STATUS:CONFIRMED
17+
URL:https://example.com/
18+
DTSTART;VALUE=DATE:20181030
19+
DTEND;VALUE=DATE:20181031
20+
END:VEVENT
21+
BEGIN:VEVENT
22+
DESCRIPTION:Event with Status
23+
SUMMARY:Cancelled Event
24+
STATUS:CANCELLED
25+
DTSTART;VALUE=DATE:20181030
26+
DTEND;VALUE=DATE:20181031
27+
END:VEVENT
28+
BEGIN:VEVENT
29+
DESCRIPTION:Event with Status
30+
SUMMARY:XPARAM Event
31+
STATUS;X-SOMETHING=IGNOREME:CANCELLED
32+
DTSTART;VALUE=DATE:20181030
33+
DTEND;VALUE=DATE:20181031
34+
END:VEVENT
35+
BEGIN:VEVENT
36+
DESCRIPTION:Event without Status
37+
SUMMARY:Event
38+
DTSTART;VALUE=DATE:20181030
39+
DTEND;VALUE=DATE:20181031
40+
END:VEVENT
41+
END:VCALENDAR

test/test_icalevents.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,17 @@ def test_transparent(self):
421421

422422
self.assertEqual(e1.transparent, True, "respect transparency")
423423
self.assertEqual(e2.transparent, False, "respect opaqueness")
424+
425+
def test_status_and_url(self):
426+
ical = "test/test_data/status_and_url.ics"
427+
start = date(2018, 10, 30)
428+
end = date(2018, 10, 31)
429+
430+
[ev1, ev2, ev3, ev4, ev5] = icalevents.events(file=ical, start=start, end=end)
431+
self.assertEqual(ev1.status, "TENTATIVE")
432+
self.assertEqual(ev1.url, None)
433+
self.assertEqual(ev2.status, "CONFIRMED")
434+
self.assertEqual(ev2.url, "https://example.com/")
435+
self.assertEqual(ev3.status, "CANCELLED")
436+
self.assertEqual(ev4.status, "CANCELLED")
437+
self.assertEqual(ev5.status, None)

0 commit comments

Comments
 (0)