[CalendarServer-changes] [6949] CalendarServer/branches/users/glyph/dalify/txdav

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 16 06:29:10 PST 2011


Revision: 6949
          http://trac.macosforge.org/projects/calendarserver/changeset/6949
Author:   glyph at apple.com
Date:     2011-02-16 06:29:10 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
some light test coverage for syncToken / resourceNamesSinceToken, fix the query based on it.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py
    CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/common.py
    CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/test_file.py
    CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/test_scheduling.py
    CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py
    CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py

Modified: CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py	2011-02-16 14:28:56 UTC (rev 6948)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py	2011-02-16 14:29:10 UTC (rev 6949)
@@ -79,6 +79,7 @@
 
     # structured tables.  (new, preferred)
     _homeSchema = schema.CALENDAR_HOME
+    _bindSchema = schema.CALENDAR_BIND
     _homeMetaDataSchema = schema.CALENDAR_HOME_METADATA
     _revisionsSchema = schema.CALENDAR_OBJECT_REVISIONS
 

Modified: CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/common.py	2011-02-16 14:28:56 UTC (rev 6948)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/common.py	2011-02-16 14:29:10 UTC (rev 6949)
@@ -1229,6 +1229,49 @@
 
 
     @inlineCallbacks
+    def test_simpleHomeSyncToken(self):
+        """
+        L{ICalendarHome.resourceNamesSinceToken} will return the names of
+        calenars created since L{ICalendarHome.syncToken} last returned a
+        particular value.
+        """
+        home = yield self.homeUnderTest()
+        cal = yield self.calendarUnderTest()
+        st = yield home.syncToken()
+        yield cal.createCalendarObjectWithName("new.ics", VComponent.fromString(
+                self.eventWithDropbox
+            )
+        )
+
+        yield cal.removeCalendarObjectWithName("2.ics")
+        st2 = yield home.syncToken()
+        self.failIfEquals(st, st2)
+
+        def token2revision(token):
+            # FIXME: the API name is a misnomer; there's syncToken() and
+            # resourceNamesSinceToken(), but actually it is resource names since
+            # *revision* and you need to understand the structure of the tokens
+            # to extract the revision.
+            uuid, rev = token.split("#", 1)
+            rev = int(rev)
+            return rev
+
+        home = yield self.homeUnderTest()
+
+        changed, deleted = yield home.resourceNamesSinceToken(
+            token2revision(st), "depth_is_ignored")
+
+        self.assertEquals(set(changed), set(["calendar_1/new.ics",
+                                             "calendar_1/2.ics"]))
+        self.assertEquals(set(deleted), set(["calendar_1/2.ics"]))
+
+        changed, deleted = yield home.resourceNamesSinceToken(
+            token2revision(st2), "depth_is_ignored")
+        self.assertEquals(changed, [])
+        self.assertEquals(deleted, [])
+
+
+    @inlineCallbacks
     def test_dropboxIDs(self):
         """
         L{ICalendarObject.getAllDropboxIDs} returns a L{Deferred} that fires

Modified: CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/test_file.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/test_file.py	2011-02-16 14:28:56 UTC (rev 6948)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/test_file.py	2011-02-16 14:29:10 UTC (rev 6949)
@@ -495,3 +495,12 @@
         (yield self.homeUnderTest())._path.child(".foo").createDirectory()
         yield self.test_calendarObjects()
 
+
+    def test_simpleHomeSyncToken(self):
+        """
+        File store doesn't have a functioning C{resourceNamesSinceToken} for
+        L{CalendarHome}.
+        """
+
+    test_simpleHomeSyncToken.skip = "Not in file store."
+

Modified: CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/test_scheduling.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/test_scheduling.py	2011-02-16 14:28:56 UTC (rev 6948)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/test/test_scheduling.py	2011-02-16 14:29:10 UTC (rev 6949)
@@ -26,9 +26,8 @@
 scheduling or data caching as middleware in the data-store layer.
 """
 
-from twisted.trial.unittest import TestCase
-from txdav.caldav.datastore.test.common import CommonTests
-from txdav.caldav.datastore.test.test_file import setUpCalendarStore
+from twisted.trial.unittest import TestCase, SkipTest
+from txdav.caldav.datastore.test.test_file import FileStorageTests
 from txdav.caldav.datastore.scheduling import ImplicitStore
 
 simpleEvent = """BEGIN:VCALENDAR
@@ -45,7 +44,7 @@
 END:VCALENDAR
 """
 
-class ImplicitStoreTests(CommonTests, TestCase):
+class ImplicitStoreTests(FileStorageTests, TestCase):
     """
     Tests for L{ImplicitSchedulingStore}.
     """
@@ -54,6 +53,12 @@
 
     def storeUnderTest(self):
         if self.implicitStore is None:
-            setUpCalendarStore(self)
-            self.implicitStore = ImplicitStore(self.calendarStore)
+            sut = FileStorageTests.storeUnderTest(self)
+            self.implicitStore = ImplicitStore(sut)
         return self.implicitStore
+
+    def skipit(self):
+        raise SkipTest("No private attribute tests.")
+
+    test_calendarObjectsWithDotFile = skipit
+    test_init = skipit

Modified: CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py	2011-02-16 14:28:56 UTC (rev 6948)
+++ CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py	2011-02-16 14:29:10 UTC (rev 6949)
@@ -66,6 +66,7 @@
 
     # structured tables.  (new, preferred)
     _homeSchema = schema.ADDRESSBOOK_HOME
+    _bindSchema = schema.ADDRESSBOOK_BIND
     _homeMetaDataSchema = schema.ADDRESSBOOK_HOME_METADATA
     _revisionsSchema = schema.ADDRESSBOOK_OBJECT_REVISIONS
 

Modified: CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:28:56 UTC (rev 6948)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:29:10 UTC (rev 6949)
@@ -646,9 +646,9 @@
         return Select(
             [Max(rev.REVISION)],
             From=rev, Where=(
-                rev.RESOURCE_ID in Select(
+                rev.RESOURCE_ID.In(Select(
                     [bind.RESOURCE_ID], From=bind,
-                    Where=bind.HOME_RESOURCE_ID == Parameter("resourceID"))
+                    Where=bind.HOME_RESOURCE_ID == Parameter("resourceID")))
             ).Or((rev.HOME_RESOURCE_ID == Parameter("resourceID")).And(
                 rev.RESOURCE_ID == None))
         )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/9fa39df7/attachment-0001.html>


More information about the calendarserver-changes mailing list