[CalendarServer-changes] [7466] CalendarServer/branches/users/glyph/new-export

source_changes at macosforge.org source_changes at macosforge.org
Mon May 16 07:44:23 PDT 2011


Revision: 7466
          http://trac.macosforge.org/projects/calendarserver/changeset/7466
Author:   glyph at apple.com
Date:     2011-05-16 07:44:23 -0700 (Mon, 16 May 2011)
Log Message:
-----------
VTIMEZONE deduplication, plus some events to test it with.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/new-export/calendarserver/tools/export.py
    CalendarServer/branches/users/glyph/new-export/calendarserver/tools/test/test_export.py

Added Paths:
-----------
    CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/AnotherEvent.ics
    CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/OneEvent.ics
    CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/ThirdEvent.ics

Modified: CalendarServer/branches/users/glyph/new-export/calendarserver/tools/export.py
===================================================================
--- CalendarServer/branches/users/glyph/new-export/calendarserver/tools/export.py	2011-05-16 14:44:09 UTC (rev 7465)
+++ CalendarServer/branches/users/glyph/new-export/calendarserver/tools/export.py	2011-05-16 14:44:23 UTC (rev 7466)
@@ -157,7 +157,12 @@
         for obj in (yield calendar.calendarObjects()):
             evt = yield obj.component()
             for sub in evt.subcomponents():
-                comp.addComponent(sub)
+                if sub.name() != 'VTIMEZONE':
+                    # Omit all VTIMEZONE components, since PyCalendar will
+                    # helpfully re-include all necessary VTIMEZONEs when we call
+                    # __str__; see pycalendar.calendar.PyCalendar.generate() and
+                    # .includeTimezones().
+                    comp.addComponent(sub)
 
     fileobj.write(str(comp))
 
@@ -274,7 +279,6 @@
                     childCalendar = Component.fromString(childData)
                 except ValueError:
                     continue
-                assert childCalendar.name() == "VCALENDAR"
 
                 if uid in uids:
                     sys.stderr.write("Skipping duplicate event UID %r from %s\n" % (uid, collection.fp.path))

Modified: CalendarServer/branches/users/glyph/new-export/calendarserver/tools/test/test_export.py
===================================================================
--- CalendarServer/branches/users/glyph/new-export/calendarserver/tools/test/test_export.py	2011-05-16 14:44:09 UTC (rev 7465)
+++ CalendarServer/branches/users/glyph/new-export/calendarserver/tools/test/test_export.py	2011-05-16 14:44:23 UTC (rev 7466)
@@ -45,13 +45,21 @@
             .getContent()
     )
 
+def sample(name):
+    return (
+        getModule("twistedcaldav.test").filePath
+        .sibling("data").child(name + ".ics").getContent()
+    )
+
 valentines = holiday("C31854DA-1ED0-11D9-A5E0-000A958A3252")
 newYears = holiday("C3184A66-1ED0-11D9-A5E0-000A958A3252")
-payday = (
-    getModule("twistedcaldav.test").filePath
-    .sibling("data").child("PayDay.ics").getContent()
-)
+payday = sample("PayDay")
 
+one = sample("OneEvent")
+another = sample("AnotherEvent")
+third = sample("ThirdEvent")
+
+
 class CommandLine(TestCase):
     """
     Simple tests for command-line parsing.
@@ -234,3 +242,52 @@
         self.assertEquals(Component.fromString(io.getvalue()),
                           expected)
 
+
+    @inlineCallbacks
+    def test_onlyOneVTIMEZONE(self):
+        """
+        C{VTIMEZONE} subcomponents with matching TZIDs in multiple event
+        calendar objects should only be rendered in the resulting output once.
+
+        (Note that the code to suppor this is actually in PyCalendar, not the
+        export tool itself.)
+        """
+        yield populateCalendarsFrom(
+            {
+                "home1": {
+                    "calendar1": {
+                        "1.ics": (one, {}), # EST
+                        "2.ics": (another, {}), # EST
+                        "3.ics": (third, {}) # PST
+                    }
+                }
+            }, self.store
+        )
+
+        io = StringIO()
+        yield exportToFile(
+            [(yield self.txn().calendarHomeWithUID("home1"))
+              .calendarWithName("calendar1")],
+            "nobody", io
+        )
+        result = Component.fromString(io.getvalue())
+
+        def filtered(name):
+            for c in result.subcomponents():
+                if c.name() == name:
+                    yield c
+
+        timezones = list(filtered("VTIMEZONE"))
+        events = list(filtered("VEVENT"))
+
+        # Sanity check to make sure we picked up all three events:
+        self.assertEquals(len(events), 3)
+
+        self.assertEquals(len(timezones), 2)
+        self.assertEquals(set([tz.propertyValue("TZID") for tz in timezones]),
+
+                          # Use an intentionally wrong TZID in order to make
+                          # sure we don't depend on caching effects elsewhere.
+                          set(["America/New_Yrok", "US/Pacific"]))
+
+

Added: CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/AnotherEvent.ics
===================================================================
--- CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/AnotherEvent.ics	                        (rev 0)
+++ CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/AnotherEvent.ics	2011-05-16 14:44:23 UTC (rev 7466)
@@ -0,0 +1,32 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.4//EN
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:America/New_Yrok
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0500
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+DTSTART:20070311T020000
+TZNAME:EDT
+TZOFFSETTO:-0400
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0400
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+DTSTART:20071104T020000
+TZNAME:EST
+TZOFFSETTO:-0500
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+CREATED:20110516T031511Z
+UID:1C4B4547-9D99-446B-B1D7-135AE04A319E
+DTEND;TZID=America/New_Yrok:20110516T130000
+TRANSP:OPAQUE
+SUMMARY:Another Event
+DTSTART;TZID=America/New_Yrok:20110516T114500
+DTSTAMP:20110516T031514Z
+SEQUENCE:2
+END:VEVENT
+END:VCALENDAR

Added: CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/OneEvent.ics
===================================================================
--- CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/OneEvent.ics	                        (rev 0)
+++ CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/OneEvent.ics	2011-05-16 14:44:23 UTC (rev 7466)
@@ -0,0 +1,32 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.4//EN
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:America/New_Yrok
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0500
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+DTSTART:20070311T020000
+TZNAME:EDT
+TZOFFSETTO:-0400
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0400
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+DTSTART:20071104T020000
+TZNAME:EST
+TZOFFSETTO:-0500
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+CREATED:20110516T031505Z
+UID:89E0257D-3522-4423-B94E-60FF10BDAAFA
+DTEND;TZID=America/New_Yrok:20110516T110000
+TRANSP:OPAQUE
+SUMMARY:One Event
+DTSTART;TZID=America/New_Yrok:20110516T094500
+DTSTAMP:20110516T031511Z
+SEQUENCE:2
+END:VEVENT
+END:VCALENDAR

Added: CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/ThirdEvent.ics
===================================================================
--- CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/ThirdEvent.ics	                        (rev 0)
+++ CalendarServer/branches/users/glyph/new-export/twistedcaldav/test/data/ThirdEvent.ics	2011-05-16 14:44:23 UTC (rev 7466)
@@ -0,0 +1,32 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.4//EN
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:US/Pacific
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0800
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+DTSTART:20070311T020000
+TZNAME:PDT
+TZOFFSETTO:-0700
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0700
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+DTSTART:20071104T020000
+TZNAME:PST
+TZOFFSETTO:-0800
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+CREATED:20110516T033401Z
+UID:39F43724-3103-4379-9A0A-11FAD4FF542A
+DTEND;TZID=US/Pacific:20110516T114500
+TRANSP:OPAQUE
+SUMMARY:Third Event
+DTSTART;TZID=US/Pacific:20110516T104500
+DTSTAMP:20110516T033404Z
+SEQUENCE:2
+END:VEVENT
+END:VCALENDAR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110516/96924cf3/attachment-0001.html>


More information about the calendarserver-changes mailing list