From a136fd8fe8c148a8dcb36e192d90d23c23f7e38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20M=C3=B8llerh=C3=B8j?= Date: Wed, 7 Jun 2017 15:43:39 +0200 Subject: [PATCH] Extension to unit tests that demonstrates bug in sharedToCollectionsReconcile migration code. The problem occurs when more than one collection with same ownerUID shared to the migrating user exists. --- .../datastore/podding/migration/test/test_home_sync.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/txdav/common/datastore/podding/migration/test/test_home_sync.py b/txdav/common/datastore/podding/migration/test/test_home_sync.py index d056047d8..706013210 100644 --- a/txdav/common/datastore/podding/migration/test/test_home_sync.py +++ b/txdav/common/datastore/podding/migration/test/test_home_sync.py @@ -1285,11 +1285,13 @@ def populate(self): } @inlineCallbacks - def _createShare(self, shareFrom, shareTo, accept=True): + def _createShare(self, shareFrom, shareTo, accept=True, name="calendar"): # Invite txnindex = 1 if shareFrom[0] == "p" else 0 home = yield self.homeUnderTest(txn=self.theTransactionUnderTest(txnindex), name=shareFrom, create=True) - calendar = yield home.childWithName("calendar") + if name != "calendar": + yield home.createChildWithName(name) + calendar = yield home.childWithName(name) shareeView = yield calendar.inviteUIDToShare(shareTo, _BIND_MODE_READ, "summary") yield self.commitTransaction(txnindex) @@ -1323,6 +1325,7 @@ def test_shared_collections_reconcile(self): # Shared to migrating user shared_name_04 = yield self._createShare("user04", "user01") + shared_name_04a = yield self._createShare("user04", "user01", True, "shared") shared_name_05 = yield self._createShare("puser05", "user01") # Sync from remote side @@ -1333,7 +1336,7 @@ def test_shared_collections_reconcile(self): changes = yield syncer.sharedByCollectionsReconcile() self.assertEqual(changes, 2) changes = yield syncer.sharedToCollectionsReconcile() - self.assertEqual(changes, 2) + self.assertEqual(changes, 3) # Local calendar exists with shares home1 = yield self.homeUnderTest(txn=self.theTransactionUnderTest(1), name="user01", status=_HOME_STATUS_MIGRATING)