[CalendarServer-changes] [8229] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 26 13:54:57 PDT 2011


Revision: 8229
          http://trac.macosforge.org/projects/calendarserver/changeset/8229
Author:   cdaboo at apple.com
Date:     2011-10-26 13:54:57 -0700 (Wed, 26 Oct 2011)
Log Message:
-----------
Fix issue where component derivation can cause multiple STATUS properties to be present.

Modified Paths:
--------------
    CalendarServer/trunk/support/build.sh
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/test/test_icalendar.py

Modified: CalendarServer/trunk/support/build.sh
===================================================================
--- CalendarServer/trunk/support/build.sh	2011-10-26 18:15:02 UTC (rev 8228)
+++ CalendarServer/trunk/support/build.sh	2011-10-26 20:54:57 UTC (rev 8229)
@@ -718,7 +718,7 @@
     "${pypi}/p/python-ldap/${ld}.tar.gz";
 
   # XXX actually PyCalendar should be imported in-place.
-  py_dependency -fe -i "src" -r 174 \
+  py_dependency -fe -i "src" -r 179 \
     "pycalendar" "pycalendar" "pycalendar" \
     "http://svn.mulberrymail.com/repos/PyCalendar/branches/server";
 

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2011-10-26 18:15:02 UTC (rev 8228)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2011-10-26 20:54:57 UTC (rev 8229)
@@ -1167,7 +1167,7 @@
         newcomp.addProperty(Property("RECURRENCE-ID", dtstart.value(), params={}))
         
         if didCancel:
-            newcomp.addProperty(Property("STATUS", "CANCELLED"))
+            newcomp.replaceProperty(Property("STATUS", "CANCELLED"))
 
         # After creating/changing a component we need to do this to keep PyCalendar happy
         newcomp._pycalendar.finalise()

Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2011-10-26 18:15:02 UTC (rev 8228)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2011-10-26 20:54:57 UTC (rev 8229)
@@ -3531,6 +3531,73 @@
                 derived = str(derived).replace("\r", "") if derived else None
                 self.assertEqual(derived, result, "Failed derive instance test: %s" % (title,))
 
+    def test_derive_instance_with_cancel(self):
+        """
+        Test that derivation of cancelled instances works and only results in one STATUS property present.
+        """
+        
+        data = (
+            (
+                "1.1 - simple no existing STATUS",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20090101T080000Z
+DTEND:20090101T090000Z
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+EXDATE:20090102T080000Z
+END:VEVENT
+END:VCALENDAR
+""",
+                PyCalendarDateTime(2009, 1, 2, 8, 0, 0, tzid=PyCalendarTimezone(utc=True)),
+                """BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20090102T080000Z
+DTSTART:20090102T080000Z
+DTEND:20090102T090000Z
+DTSTAMP:20080601T120000Z
+STATUS:CANCELLED
+END:VEVENT
+""",
+            ),
+            (
+                "1.2 - simple with existing STATUS",
+                """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-1
+DTSTART:20090101T080000Z
+DTEND:20090101T090000Z
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+EXDATE:20090102T080000Z
+STATUS:CONFIRMED
+END:VEVENT
+END:VCALENDAR
+""",
+                PyCalendarDateTime(2009, 1, 2, 8, 0, 0, tzid=PyCalendarTimezone(utc=True)),
+                """BEGIN:VEVENT
+UID:12345-67890-1
+RECURRENCE-ID:20090102T080000Z
+DTSTART:20090102T080000Z
+DTEND:20090102T090000Z
+DTSTAMP:20080601T120000Z
+STATUS:CANCELLED
+END:VEVENT
+""",
+            ),
+        )
+        
+        for title, calendar, rid, result in data:
+            ical = Component.fromString(calendar)
+            derived = ical.deriveInstance(rid, allowCancelled=True)
+            derived = str(derived).replace("\r", "") if derived else None
+            self.assertEqual(derived, result, "Failed derive instance test: %s" % (title,))
+
     def test_truncate_recurrence(self):
         
         data = (
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111026/40d4f64a/attachment-0001.html>


More information about the calendarserver-changes mailing list