[CalendarServer-changes] [8702] CalendarServer/branches/users/glyph/migrate-merge

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 16 04:29:08 PST 2012


Revision: 8702
          http://trac.macosforge.org/projects/calendarserver/changeset/8702
Author:   glyph at apple.com
Date:     2012-02-16 04:29:08 -0800 (Thu, 16 Feb 2012)
Log Message:
-----------
test for not deleting default calendarswhen merging

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/test/test_util.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/migrate-merge/

Modified: CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/test/test_util.py
===================================================================
--- CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/test/test_util.py	2012-02-16 12:29:05 UTC (rev 8701)
+++ CalendarServer/branches/users/glyph/migrate-merge/txdav/caldav/datastore/test/test_util.py	2012-02-16 12:29:08 UTC (rev 8702)
@@ -534,21 +534,64 @@
         )
         yield migrateHome(c1, c2, merge=True)
         targetCal = yield c2.calendarWithName("conflicted")
-        @inlineCallbacks
-        def checkSummary(name, summary, cal=targetCal):
-            obj = yield cal.calendarObjectWithName(name)
-            if summary is None:
-                self.assertIdentical(obj, None,
-                                     name + " existed but shouldn't have")
-            else:
-                txt = ((yield obj.component()).mainComponent()
-                       .getProperty("SUMMARY").value())
-                self.assertEquals(txt, summary)
-        yield checkSummary("same-name", "target")
-        yield checkSummary("different-name", "tgt other")
-        yield checkSummary("other-calendar", None)
-        yield checkSummary("other-name", None)
-        yield checkSummary("no-conflict", "okay")
-        yield checkSummary("oc", "target calendar", otherCal)
+        yield self.checkSummary("same-name", "target", targetCal)
+        yield self.checkSummary("different-name", "tgt other", targetCal)
+        yield self.checkSummary("other-calendar", None, targetCal)
+        yield self.checkSummary("other-name", None, targetCal)
+        yield self.checkSummary("no-conflict", "okay", targetCal)
+        yield self.checkSummary("oc", "target calendar", otherCal)
 
-    # TODO: don't delete default calendar in merge mode.
+
+    @inlineCallbacks
+    def checkSummary(self, name, summary, cal):
+        """
+        Verify that the summary of the calendar object for the given name in
+        the given calendar matches.
+        """
+        obj = yield cal.calendarObjectWithName(name)
+        if summary is None:
+            self.assertIdentical(obj, None,
+                                 name + " existed but shouldn't have")
+        else:
+            txt = ((yield obj.component()).mainComponent()
+                   .getProperty("SUMMARY").value())
+            self.assertEquals(txt, summary)
+
+
+    @inlineCallbacks
+    def test_migrateMergeDontDeleteDefault(self):
+        """
+        If we're doing a merge migration, it's quite possible that the user has
+        scheduled events onto their default calendar already.  In fact the
+        whole point of a merge migration is to preserve data that might have
+        been created there.  So, let's make sure that we I{don't} delete any
+        data from the default calendars in the case that we're merging.
+        """
+        yield populateCalendarsFrom({
+            "empty_home": {
+                # see test_migrateEmptyHome above.
+                "other-default-calendar": {}
+            },
+            "non_empty_home": {
+                "calendar": {
+                    "some-name": self.sampleEvent("some-uid", "some summary"),
+                }, "inbox": {}, "tasks": {}
+            }
+        }, self.storeUnderTest())
+        txn = self.transactionUnderTest()
+        emptyHome = yield txn.calendarHomeWithUID("empty_home")
+        self.assertIdentical((yield emptyHome.calendarWithName("calendar")),
+                             None)
+        nonEmpty = yield txn.calendarHomeWithUID("non_empty_home")
+        yield migrateHome(emptyHome, nonEmpty)
+        yield self.commit()
+        txn = self.transactionUnderTest()
+        emptyHome = yield txn.calendarHomeWithUID("empty_home")
+        nonEmpty = yield txn.calendarHomeWithUID("non_empty_home")
+        self.assertNotIdentical(
+            (yield nonEmpty.calendarWithName("inbox")), None
+        )
+        defaultCal = (yield nonEmpty.calendarWithName("calendar"))
+        self.assertNotIdentical(
+            (yield defaultCal.calendarObjectWithName("some-name")), None
+        )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120216/2373ac39/attachment-0001.html>


More information about the calendarserver-changes mailing list