icalendar/master: Test for VTIMEZONES with RDATEs

Christian Geier <jenkins-z4DKO/[email protected]>
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: icalendar
Branch: refs/heads/master
Date: 2017-07-02T19:42:02+02:00
Author: Christian Geier (geier) <[email protected]>
Commit: https://github.com/collective/icalendar/commit/4d1311fc766d5bbf7d3aea10c89878d611769f27

Test for VTIMEZONES with RDATEs

Files changed:
A src/icalendar/tests/timezone_rdate.ics
M src/icalendar/tests/test_timezoned.py

diff --git a/src/icalendar/tests/test_timezoned.py b/src/icalendar/tests/test_timezoned.py
index d09e85c..068c116 100644
--- a/src/icalendar/tests/test_timezoned.py
+++ b/src/icalendar/tests/test_timezoned.py
@@ -338,3 +338,35 @@ def test_same_start_date_and_offset(self):
         cal = icalendar.Calendar.from_ical(data)
         d = cal.subcomponents[1]['DTSTART'].dt
         self.assertEqual(d.strftime('%c'), 'Fri Feb 24 12:00:00 2017')
+
+    def test_rdate(self):
+        """testing if we can handle VTIMEZONEs who only have an RDATE, not RRULE
+        """
+        directory = os.path.dirname(__file__)
+        with open(os.path.join(directory, 'timezone_rdate.ics'), 'rb') as fp:
+            data = fp.read()
+        cal = icalendar.Calendar.from_ical(data)
+        vevent = cal.walk('VEVENT')[0]
+        tz = vevent['DTSTART'].dt.tzinfo
+        self.assertEqual(str(tz), 'posix/Europe/Vaduz')
+        self.assertEqual(
+            tz._utc_transition_times[:6],
+            [
+                datetime.datetime(1901, 12, 13, 20, 45, 38),
+                datetime.datetime(1941, 5, 5, 0, 0, 0),
+                datetime.datetime(1941, 10, 6, 0, 0, 0),
+                datetime.datetime(1942, 5, 4, 0, 0, 0),
+                datetime.datetime(1942, 10, 5, 0, 0, 0),
+                datetime.datetime(1981, 3, 29, 1, 0),
+            ])
+        self.assertEqual(
+            tz._transition_info[:6],
+            [
+                (datetime.timedelta(0, 3600), datetime.timedelta(0), 'CET'),
+                (datetime.timedelta(0, 7200), datetime.timedelta(0, 3600), 'CEST'),
+                (datetime.timedelta(0, 3600), datetime.timedelta(0), 'CET'),
+                (datetime.timedelta(0, 7200), datetime.timedelta(0, 3600), 'CEST'),
+                (datetime.timedelta(0, 3600), datetime.timedelta(0), 'CET'),
+                (datetime.timedelta(0, 7200), datetime.timedelta(0, 3600), 'CEST'),
+            ]
+        )
diff --git a/src/icalendar/tests/timezone_rdate.ics b/src/icalendar/tests/timezone_rdate.ics
new file mode 100644
index 0000000..5a4f7a9
--- /dev/null
+++ b/src/icalendar/tests/timezone_rdate.ics
@@ -0,0 +1,55 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VTIMEZONE
+TZID:posix/Europe/Vaduz
+BEGIN:STANDARD
+TZNAME:CET
+TZOFFSETFROM:+002946
+TZOFFSETTO:+0100
+DTSTART:19011213T211538
+RDATE;VALUE=DATE-TIME:19011213T211538
+END:STANDARD
+BEGIN:DAYLIGHT
+TZNAME:CEST
+TZOFFSETFROM:+0100
+TZOFFSETTO:+0200
+DTSTART:19810329T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
+END:DAYLIGHT
+BEGIN:DAYLIGHT
+TZNAME:CEST
+TZOFFSETFROM:+0100
+TZOFFSETTO:+0200
+DTSTART:19410505T010000
+RDATE;VALUE=DATE-TIME:19410505T010000
+RDATE;VALUE=DATE-TIME:19420504T010000
+END:DAYLIGHT
+BEGIN:STANDARD
+TZNAME:CET
+TZOFFSETFROM:+0200
+TZOFFSETTO:+0100
+DTSTART:19810927T030000
+RRULE:FREQ=YEARLY;COUNT=15;BYDAY=-1SU;BYMONTH=9
+END:STANDARD
+BEGIN:STANDARD
+TZNAME:CET
+TZOFFSETFROM:+0200
+TZOFFSETTO:+0100
+DTSTART:19961027T030000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+END:STANDARD
+BEGIN:STANDARD
+TZNAME:CET
+TZOFFSETFROM:+0200
+TZOFFSETTO:+0100
+DTSTART:19411006T020000
+RDATE;VALUE=DATE-TIME:19411006T020000
+RDATE;VALUE=DATE-TIME:19421005T020000
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:123
+DTSTART;TZID=posix/Europe/Vaduz:20120213T100000
+SUMMARY=testevent
+END:VEVENT
+END:VCALENDAR



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.