[CalendarServer-changes] [11291] CalendarServer/trunk/txdav

source_changes at macosforge.org source_changes at macosforge.org
Tue Jun 4 12:13:32 PDT 2013


Revision: 11291
          http://trac.calendarserver.org//changeset/11291
Author:   cdaboo at apple.com
Date:     2013-06-04 12:13:32 -0700 (Tue, 04 Jun 2013)
Log Message:
-----------
Make sure migration copes with "orphaned" per-user properties.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/caldav/datastore/test/util.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_4_to_5.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_3_to_4.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_4_to_5.py

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/util.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/util.py	2013-06-04 19:10:22 UTC (rev 11290)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/util.py	2013-06-04 19:13:32 UTC (rev 11291)
@@ -224,6 +224,12 @@
             "inbox": {
             },
         },
+        "user04": {
+            "calendar_1": {
+            },
+            "inbox": {
+            },
+        },
     }
 
 

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_4_to_5.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_4_to_5.py	2013-06-04 19:10:22 UTC (rev 11290)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_4_to_5.py	2013-06-04 19:13:32 UTC (rev 11291)
@@ -96,7 +96,8 @@
                 if calendarHome is not None:
                     prop = WebDAVDocument.fromString(value).root_element
                     calendar = (yield calendarHome.childWithID(calendar_rid))
-                    yield calendar.setTimezone(prop.calendar())
+                    if calendar is not None:
+                        yield calendar.setTimezone(prop.calendar())
 
             # Always delete the rows so that batch processing works correctly
             yield Delete(

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_3_to_4.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_3_to_4.py	2013-06-04 19:10:22 UTC (rev 11290)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_3_to_4.py	2013-06-04 19:13:32 UTC (rev 11291)
@@ -18,12 +18,12 @@
 from txdav.base.propertystore.base import PropertyName
 from txdav.caldav.datastore.test.util import CommonStoreTests
 from txdav.xml.element import HRef
-from twext.enterprise.dal.syntax import Update
+from twext.enterprise.dal.syntax import Update, Insert
 from txdav.common.datastore.upgrade.sql.upgrades.calendar_upgrade_from_3_to_4 import moveDefaultCalendarProperties, \
     moveCalendarTranspProperties, removeResourceType, moveDefaultAlarmProperties
 from txdav.xml import element
 from twistedcaldav import caldavxml
-from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE
+from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE, schema
 
 """
 Tests for L{txdav.common.datastore.upgrade.sql.upgrade}.
@@ -104,6 +104,20 @@
             self.assertTrue(PropertyName.fromElement(CalendarFreeBusySet) in inbox.properties())
         yield self.commit()
 
+        # Create "fake" entry for non-existent share
+        txn = self.transactionUnderTest()
+        calendar = (yield self.calendarUnderTest(name="calendar_1", home="user01"))
+        rp = schema.RESOURCE_PROPERTY
+        yield Insert(
+            {
+                rp.RESOURCE_ID: calendar._resourceID,
+                rp.NAME: PropertyName.fromElement(ScheduleCalendarTransp).toString(),
+                rp.VALUE: ScheduleCalendarTransp(Opaque()).toxml(),
+                rp.VIEWER_UID: "user03",
+            }
+        ).on(txn)
+        yield self.commit()
+
         # Trigger upgrade
         yield moveCalendarTranspProperties(self._sqlCalendarStore)
 

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_4_to_5.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_4_to_5.py	2013-06-04 19:10:22 UTC (rev 11290)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/test/test_upgrade_from_4_to_5.py	2013-06-04 19:13:32 UTC (rev 11291)
@@ -16,14 +16,14 @@
 from twistedcaldav import caldavxml, customxml
 from txdav.common.datastore.upgrade.sql.upgrades.calendar_upgrade_from_4_to_5 import moveCalendarTimezoneProperties, \
     removeOtherProperties, moveCalendarAvailabilityProperties
-from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE
+from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE, schema
 from txdav.xml import element
 
 """
 Tests for L{txdav.common.datastore.upgrade.sql.upgrade}.
 """
 
-from twext.enterprise.dal.syntax import Update
+from twext.enterprise.dal.syntax import Update, Insert
 from twisted.internet.defer import inlineCallbacks
 from twistedcaldav.ical import Component
 from txdav.base.propertystore.base import PropertyName
@@ -123,6 +123,20 @@
             self.assertEqual(PropertyName.fromElement(caldavxml.CalendarTimeZone) in calendar.properties(), tz is not None)
         yield self.commit()
 
+        # Create "fake" entry for non-existent share
+        txn = self.transactionUnderTest()
+        calendar = (yield self.calendarUnderTest(name="calendar_1", home="user01"))
+        rp = schema.RESOURCE_PROPERTY
+        yield Insert(
+            {
+                rp.RESOURCE_ID: calendar._resourceID,
+                rp.NAME: PropertyName.fromElement(caldavxml.CalendarTimeZone).toString(),
+                rp.VALUE: caldavxml.CalendarTimeZone.fromString(str(tz3)).toxml(),
+                rp.VIEWER_UID: "user04",
+            }
+        ).on(txn)
+        yield self.commit()
+
         # Trigger upgrade
         yield moveCalendarTimezoneProperties(self._sqlCalendarStore)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130604/bf4eed66/attachment-0001.html>


More information about the calendarserver-changes mailing list