[CalendarServer-changes] [8135] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Sep 30 09:20:23 PDT 2011


Revision: 8135
          http://trac.macosforge.org/projects/calendarserver/changeset/8135
Author:   cdaboo at apple.com
Date:     2011-09-30 09:20:20 -0700 (Fri, 30 Sep 2011)
Log Message:
-----------
Fix freebusy transparency lookup of migrated calendar data.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/test/test_wrapping.py
    CalendarServer/trunk/txdav/caldav/datastore/test/common.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
    CalendarServer/trunk/txdav/common/datastore/sql_legacy.py

Added Paths:
-----------
    CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home1/calendar_1/4.ics

Modified: CalendarServer/trunk/twistedcaldav/test/test_wrapping.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_wrapping.py	2011-09-29 20:59:25 UTC (rev 8134)
+++ CalendarServer/trunk/twistedcaldav/test/test_wrapping.py	2011-09-30 16:20:20 UTC (rev 8135)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2011 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
 from twistedcaldav.test.util import TestCase
 
 from txdav.idav import IDataStore
-from txdav.caldav.datastore.test.test_file import event4_text
+from txdav.caldav.datastore.test.test_file import test_event_text
 
 from txdav.carddav.datastore.test.test_file import vcard4_text
 
@@ -382,7 +382,7 @@
         parallel L{CalendarObject} will be created.  Its principal collections
         and transaction should match.
         """
-        yield self.populateOneObject("1.ics", event4_text)
+        yield self.populateOneObject("1.ics", test_event_text)
         calendarHome = yield self.getResource("calendars/users/wsanchez")
         calDavFileCalendar = yield self.getResource(
             "calendars/users/wsanchez/calendar/1.ics"
@@ -400,9 +400,9 @@
         Exceeding quota on an attachment returns an HTTP error code.
         """
         patchConfig(testCase=self, EnableDropBox=True)
-        yield self.populateOneObject("1.ics", event4_text)
+        yield self.populateOneObject("1.ics", test_event_text)
         calendarObject = yield self.getResource(
-            "/calendars/users/wsanchez/dropbox/uid4.dropbox/too-big-attachment",
+            "/calendars/users/wsanchez/dropbox/uid-test.dropbox/too-big-attachment",
             "PUT", "wsanchez"
         )
         self.requestUnderTest.stream = MemoryStream(

Added: CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home1/calendar_1/4.ics
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home1/calendar_1/4.ics	                        (rev 0)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home1/calendar_1/4.ics	2011-09-30 16:20:20 UTC (rev 8135)
@@ -0,0 +1,16 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Cyrusoft International\, Inc.//Mulberry v4.0//EN
+BEGIN:VEVENT
+UID:uid4
+DTSTART;VALUE=DATE:20060201
+DURATION:P1D
+CREATED:20060101T210000Z
+DTSTAMP:20051222T210146Z
+LAST-MODIFIED:20051222T210203Z
+SEQUENCE:1
+SUMMARY:event 4
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/common.py	2011-09-29 20:59:25 UTC (rev 8134)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/common.py	2011-09-30 16:20:20 UTC (rev 8135)
@@ -67,6 +67,7 @@
     "1.ics",
     "2.ics",
     "3.ics",
+    "4.ics",
 ]
 
 
@@ -77,7 +78,7 @@
 ]
 
 
-event4_text = (
+test_event_text = (
     "BEGIN:VCALENDAR\r\n"
       "VERSION:2.0\r\n"
       "PRODID:-//Apple Inc.//iCal 4.0.1//EN\r\n"
@@ -101,7 +102,7 @@
       "END:VTIMEZONE\r\n"
       "BEGIN:VEVENT\r\n"
         "CREATED:20100203T013849Z\r\n"
-        "UID:uid4\r\n"
+        "UID:uid-test\r\n"
         "DTEND;TZID=US/Pacific:20100207T173000\r\n"
         "TRANSP:OPAQUE\r\n"
         "SUMMARY:New Event\r\n"
@@ -120,14 +121,14 @@
 
 
 
-event4notCalDAV_text = (
+test_event_notCalDAV_text = (
     "BEGIN:VCALENDAR\r\n"
       "VERSION:2.0\r\n"
       "PRODID:-//Apple Inc.//iCal 4.0.1//EN\r\n"
       "CALSCALE:GREGORIAN\r\n"
       "BEGIN:VEVENT\r\n"
         "CREATED:20100203T013849Z\r\n"
-        "UID:4\r\n"
+        "UID:test\r\n"
         "DTEND;TZID=US/Pacific:20100207T173000\r\n" # TZID without VTIMEZONE
         "TRANSP:OPAQUE\r\n"
         "SUMMARY:New Event\r\n"
@@ -146,8 +147,8 @@
 
 
 
-event1modified_text = event4_text.replace(
-    "\r\nUID:uid4\r\n",
+event1modified_text = test_event_text.replace(
+    "\r\nUID:uid-test\r\n",
     "\r\nUID:uid1\r\n"
 )
 
@@ -199,11 +200,19 @@
         "scheduleEtags": (),
         "hasPrivateComment": True,
     }
+    metadata4 = {
+        "accessMode": "PUBLIC",
+        "isScheduleObject": None,
+        "scheduleTag": "abc",
+        "scheduleEtags": (),
+        "hasPrivateComment": True,
+    }
 
     md5Values = (
         hashlib.md5("1234").hexdigest(),
         hashlib.md5("5678").hexdigest(),
         hashlib.md5("9ABC").hexdigest(),
+        hashlib.md5("EFGH").hexdigest(),
     )
     requirements = {
         "home1": {
@@ -211,6 +220,7 @@
                 "1.ics": (cal1Root.child("1.ics").getContent(), metadata1),
                 "2.ics": (cal1Root.child("2.ics").getContent(), metadata2),
                 "3.ics": (cal1Root.child("3.ics").getContent(), metadata3),
+                "4.ics": (cal1Root.child("4.ics").getContent(), metadata4),
             },
             "calendar_2": {},
             "calendar_empty": {},
@@ -224,6 +234,7 @@
                 "1.ics": md5Values[0],
                 "2.ics": md5Values[1],
                 "3.ics": md5Values[2],
+                "4.ics": md5Values[3],
             },
             "calendar_2": {},
             "calendar_empty": {},
@@ -785,6 +796,8 @@
                 ("update", "CalDAV|home1/calendar_1"),
                 ("update", "CalDAV|home1"),
                 ("update", "CalDAV|home1/calendar_1"),
+                ("update", "CalDAV|home1"),
+                ("update", "CalDAV|home1/calendar_1"),
             ]
         )
 
@@ -1161,11 +1174,11 @@
         L{ICalendarObject}.
         """
         calendar1 = yield self.calendarUnderTest()
-        name = "4.ics"
+        name = "test.ics"
         self.assertIdentical(
             (yield calendar1.calendarObjectWithName(name)), None
         )
-        component = VComponent.fromString(event4_text)
+        component = VComponent.fromString(test_event_text)
         metadata = {
             "accessMode": "PUBLIC",
             "isScheduleObject": True,
@@ -1199,7 +1212,7 @@
         given name already exists in that calendar.
         """
         cal = yield self.calendarUnderTest()
-        comp = VComponent.fromString(event4_text)
+        comp = VComponent.fromString(test_event_text)
         yield self.failUnlessFailure(
             maybeDeferred(cal.createCalendarObjectWithName, "1.ics", comp),
             ObjectResourceNameAlreadyExistsError,
@@ -1215,7 +1228,7 @@
         """
         yield self.failUnlessFailure(
             maybeDeferred((yield self.calendarUnderTest()).createCalendarObjectWithName,
-            "new", VComponent.fromString(event4notCalDAV_text)),
+            "new", VComponent.fromString(test_event_notCalDAV_text)),
             InvalidObjectResourceError,
         )
 
@@ -1228,7 +1241,7 @@
         calendarObject = yield self.calendarObjectUnderTest()
         yield self.failUnlessFailure(
             maybeDeferred(calendarObject.setComponent,
-                          VComponent.fromString(event4notCalDAV_text)),
+                          VComponent.fromString(test_event_notCalDAV_text)),
             InvalidObjectResourceError,
         )
 
@@ -1240,7 +1253,7 @@
         when given a L{VComponent} whose UID does not match its existing UID.
         """
         calendar1 = yield self.calendarUnderTest()
-        component = VComponent.fromString(event4_text)
+        component = VComponent.fromString(test_event_text)
         calendarObject = yield calendar1.calendarObjectWithName("1.ics")
         yield self.failUnlessFailure(
             maybeDeferred(calendarObject.setComponent, component),
@@ -1348,9 +1361,9 @@
         """
         calendar = yield self.calendarUnderTest()
         yield calendar.createCalendarObjectWithName(
-            "4.ics", VComponent.fromString(event4_text)
+            "test.ics", VComponent.fromString(test_event_text)
         )
-        newEvent = yield calendar.calendarObjectWithName("4.ics")
+        newEvent = yield calendar.calendarObjectWithName("test.ics")
         self.assertEquals(newEvent.properties().items(), [])
 
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py	2011-09-29 20:59:25 UTC (rev 8134)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_file.py	2011-09-30 16:20:20 UTC (rev 8135)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2011 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@
 
 from txdav.common.datastore.test.util import deriveQuota
 from txdav.caldav.datastore.test.common import (
-    CommonTests, event4_text, event1modified_text)
+    CommonTests, test_event_text, event1modified_text)
 
 storePath = FilePath(__file__).parent().child("calendar_store")
 
@@ -256,7 +256,7 @@
         self.assertRaises(
             ObjectResourceNameNotAllowedError,
             self.calendar1.createCalendarObjectWithName,
-            ".foo", VComponent.fromString(event4_text)
+            ".foo", VComponent.fromString(test_event_text)
         )
 
 
@@ -330,7 +330,7 @@
         yield self._refresh()
         self.calendar1.createCalendarObjectWithName(
             "sample.ics",
-            VComponent.fromString(event4_text)
+            VComponent.fromString(test_event_text)
         )
         yield self.txn.abort()
         yield self._refresh()

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py	2011-09-29 20:59:25 UTC (rev 8134)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py	2011-09-30 16:20:20 UTC (rev 8135)
@@ -31,7 +31,7 @@
 
 from txdav.base.propertystore.base import PropertyName
 from txdav.caldav.datastore.test.common import CommonTests as CalendarCommonTests,\
-    event4_text
+    test_event_text
 from txdav.caldav.datastore.test.test_file import setUpCalendarStore
 from txdav.caldav.datastore.util import _migrateCalendar, migrateHome
 from txdav.common.datastore.sql import ECALENDARTYPE
@@ -41,6 +41,7 @@
 from twistedcaldav import caldavxml
 
 from twistedcaldav.dateops import datetimeMktime
+from twistedcaldav.query import calendarqueryfilter
 from twistedcaldav.sharing import SharedCollectionRecord
 
 import datetime
@@ -187,6 +188,38 @@
         self.assertEqual(bad, 0)
 
     @inlineCallbacks
+    def test_migrateCalendarFromFile_Transparency(self):
+        """
+        C{_migrateCalendar()} can migrate a file-backed calendar to a database-
+        backed calendar.
+        """
+        fromCalendar = yield (yield self.fileTransaction().calendarHomeWithUID(
+            "home1")).calendarWithName("calendar_1")
+        toHome = yield self.transactionUnderTest().calendarHomeWithUID(
+            "new-home", create=True)
+        toCalendar = yield toHome.calendarWithName("calendar")
+        yield _migrateCalendar(fromCalendar, toCalendar,
+                               lambda x: x.component())
+
+        filter =  caldavxml.Filter(
+                      caldavxml.ComponentFilter(
+                          caldavxml.ComponentFilter(
+                              caldavxml.TimeRange(start="20060201T000000Z", end="20060202T000000Z"),
+                              name=("VEVENT", "VFREEBUSY", "VAVAILABILITY"),
+                          ),
+                          name="VCALENDAR",
+                       )
+                  )
+        filter = calendarqueryfilter.Filter(filter)
+        filter.settimezone(None)
+
+        results = yield toCalendar._index.indexedSearch(filter, 'user01', True)
+        self.assertEquals(len(results), 1)
+        _ignore_name, uid, _ignore_type, _ignore_organizer, _ignore_float, _ignore_start, _ignore_end, _ignore_fbtype, transp = results[0]
+        self.assertEquals(uid, "uid4")
+        self.assertEquals(transp, 'T')
+
+    @inlineCallbacks
     def test_migrateHomeFromFile(self):
         """
         L{migrateHome} will migrate an L{ICalendarHome} provider from one
@@ -518,8 +551,8 @@
 
         # Create calendar object
         calendar1 = yield self.calendarUnderTest()
-        name = "4.ics"
-        component = VComponent.fromString(event4_text)
+        name = "test.ics"
+        component = VComponent.fromString(test_event_text)
         metadata = {
             "accessMode": "PUBLIC",
             "isScheduleObject": True,
@@ -564,8 +597,8 @@
         home = yield self.homeUnderTest()
         inbox = yield home.createCalendarWithName("inbox")
         
-        name = "4.ics"
-        component = VComponent.fromString(event4_text)
+        name = "test.ics"
+        component = VComponent.fromString(test_event_text)
         metadata = {
             "accessMode": "PUBLIC",
             "isScheduleObject": True,

Modified: CalendarServer/trunk/txdav/common/datastore/sql_legacy.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_legacy.py	2011-09-29 20:59:25 UTC (rev 8134)
+++ CalendarServer/trunk/txdav/common/datastore/sql_legacy.py	2011-09-30 16:20:20 UTC (rev 8135)
@@ -1250,7 +1250,9 @@
                 row = list(row)
                 row[4] = 'Y' if row[4] else 'N'
                 row[7] = indexfbtype_to_icalfbtype[row[7]]
-                row[8] = 'T' if row[9] else 'F'
+                if row[9] is not None:
+                    row[8] = row[9]
+                row[8] = 'T' if row[8] else 'F'
                 del row[9]
             results.append(row)
         returnValue(results)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110930/80587140/attachment-0001.html>


More information about the calendarserver-changes mailing list