[CalendarServer-changes] [15175] CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav /datastore/scheduling/test/test_icalsplitter.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Oct 8 20:18:36 PDT 2015


Revision: 15175
          http://trac.calendarserver.org//changeset/15175
Author:   cdaboo at apple.com
Date:     2015-10-08 20:18:36 -0700 (Thu, 08 Oct 2015)
Log Message:
-----------
Fix RRULE expansion caching issue when the cached period is extended. Caused negative RRULE COUNTs when splitting in very specific situations.

Modified Paths:
--------------
    CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/test/test_icalsplitter.py

Modified: CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/test/test_icalsplitter.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/test/test_icalsplitter.py	2015-10-09 03:16:33 UTC (rev 15174)
+++ CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/test/test_icalsplitter.py	2015-10-09 03:18:36 UTC (rev 15175)
@@ -35,6 +35,8 @@
         self.now.setHHMMSS(0, 0, 0)
 
         self.subs["now"] = self.now
+        self.subs["now_1"] = self.now.duplicate()
+        self.subs["now_1"].offsetSeconds(-1)
 
         for i in range(30):
             attrname = "now_back%s" % (i + 1,)
@@ -2221,6 +2223,109 @@
             self.assertFalse(splitter.willSplit(icalOld), "Failed past will split: %s" % (title,))
 
 
+    def test_split_negative_count(self):
+
+        data = (
+            (
+                "1.1 - RRULE with override",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:%(now_back30)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RRULE:FREQ=WEEKLY;COUNT=100
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:%(now_back23)s
+DTSTART:%(now_back23)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:%(now_back16)s
+DTSTART:%(now_back16)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:%(now_fwd5)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+RRULE:FREQ=WEEKLY;COUNT=95
+END:VEVENT
+END:VCALENDAR
+""",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:%(uid)s
+DTSTART:%(now_back30)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+RRULE:FREQ=WEEKLY;UNTIL=%(now_fwd5_1)s
+END:VEVENT
+BEGIN:VEVENT
+UID:%(uid)s
+RECURRENCE-ID:%(now_back23)s
+DTSTART:%(now_back23)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+END:VEVENT
+BEGIN:VEVENT
+UID:%(uid)s
+RECURRENCE-ID:%(now_back16)s
+DTSTART:%(now_back16)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+END:VEVENT
+END:VCALENDAR
+""",
+            ),
+        )
+
+        for title, calendar, split_future, split_past in data:
+            ical = Component.fromString(calendar % self.subs)
+            splitter = iCalSplitter(100, 0)
+            if title[0] == "1":
+                self.assertTrue(splitter.willSplit(ical), "Failed will split: %s" % (title,))
+            icalOld, icalNew = splitter.split(ical)
+            relsubs = dict(self.subs)
+            relsubs["uid"] = icalOld.resourceUID()
+            relsubs["relID"] = icalOld.mainComponent().propertyValue("RELATED-TO") if icalOld.mainComponent() else icalNew.mainComponent().propertyValue("RELATED-TO")
+            self.assertEqual(str(icalNew).replace("\r\n ", ""), split_future.replace("\n", "\r\n") % relsubs, "Failed future: %s" % (title,))
+            self.assertEqual(str(icalOld).replace("\r\n ", ""), split_past.replace("\n", "\r\n") % relsubs, "Failed past: %s" % (title,))
+
+
     def test_future_split(self):
 
         data = (
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151008/30411885/attachment-0001.html>


More information about the calendarserver-changes mailing list