summaryrefslogtreecommitdiffstats
path: root/tests/unit/test-003-event.py
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2016-05-06 14:20:13 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2016-05-06 14:21:47 +0200
commit899fd8ec78ae03907f7a52b6764d25a2ff9b5cdd (patch)
treeb77deda9ad3c3fe30a710cb5b6d889aea9db8651 /tests/unit/test-003-event.py
parent249343c34f948757426538e245dafbad7fe38aa9 (diff)
downloadpykolab-899fd8ec78ae03907f7a52b6764d25a2ff9b5cdd.tar.gz
Add RDATE support (#5401)
Summary: Fixes #5401 Reviewers: #pykolab_developers, vanmeeuwen Reviewed By: #pykolab_developers, vanmeeuwen Subscribers: vanmeeuwen Differential Revision: https://git.kolab.org/D139
Diffstat (limited to 'tests/unit/test-003-event.py')
-rw-r--r--tests/unit/test-003-event.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/unit/test-003-event.py b/tests/unit/test-003-event.py
index 18b186b..a7ab82f 100644
--- a/tests/unit/test-003-event.py
+++ b/tests/unit/test-003-event.py
@@ -89,6 +89,25 @@ ORGANIZER;CN=Doe\, John:mailto:john.doe@example.org
END:VEVENT
"""
+ical_event_rdate = """
+BEGIN:VEVENT
+UID:7a35527d-f783-4b58-b404-b1389bd2fc57
+DTSTAMP;VALUE=DATE-TIME:20140407T122311Z
+CREATED;VALUE=DATE-TIME:20140407T122245Z
+LAST-MODIFIED;VALUE=DATE-TIME:20140407T122311Z
+DTSTART;TZID=Europe/Zurich;VALUE=DATE-TIME:20140523T110000
+DURATION:PT1H30M0S
+RDATE;TZID=Europe/Zurich;VALUE=DATE-TIME:20140530T110000
+RDATE;TZID=Europe/Zurich;VALUE=DATE-TIME:20140620T110000
+SUMMARY:Summary
+LOCATION:Location
+DESCRIPTION:Description
+SEQUENCE:2
+CLASS:PUBLIC
+ORGANIZER;CN=Doe\, John:mailto:john.doe@example.org
+END:VEVENT
+"""
+
xml_event = """
<icalendar xmlns="urn:ietf:params:xml:ns:icalendar-2.0">
<vcalendar>
@@ -961,6 +980,31 @@ END:VEVENT
self.assertEqual(event.get_attendee("jack@example.org").get_name(), "Jack")
self.assertRaises(ValueError, exception.get_attendee, "somebody@else.com") # not addded to exception
+ def test_028_rdate(self):
+ event = event_from_ical(ical_event_rdate)
+
+ self.assertTrue(event.is_recurring())
+ self.assertEqual(len(event.get_recurrence_dates()), 2)
+ self.assertIsInstance(event.get_recurrence_dates()[0], datetime.datetime)
+
+ rdates = event.get_recurrence_dates()
+ self.assertEqual(str(rdates[0]), "2014-05-30 11:00:00+02:00")
+ self.assertEqual(str(rdates[1]), "2014-06-20 11:00:00+02:00")
+
+ dt = datetime.datetime(2014, 8, 15, 10, 0, 0, tzinfo=pytz.timezone("Europe/Zurich"))
+ event.add_recurrence_date(dt)
+ rdates = event.get_recurrence_dates()
+ self.assertEqual(str(rdates[2]), "2014-08-15 10:00:00+02:00")
+
+ itip = event.as_string_itip()
+ rdates = []
+ for line in itip.split("\n"):
+ if re.match('^RDATE', line):
+ rdates.append(line.strip().split(':')[1])
+ self.assertEqual("TZID=Europe/Zurich", line.split(':')[0].split(';')[1])
+
+ self.assertEqual(rdates, ["20140530T110000", "20140620T110000", "20140815T100000"])
+
def _find_prop_in_list(self, diff, name):
for prop in diff:
if prop['property'] == name: