[CalendarServer-changes] [13454] CalendarServer/trunk/twistedcaldav/test

source_changes at macosforge.org source_changes at macosforge.org
Wed May 7 11:22:18 PDT 2014


Revision: 13454
          http://trac.calendarserver.org//changeset/13454
Author:   sagen at apple.com
Date:     2014-05-07 11:22:18 -0700 (Wed, 07 May 2014)
Log Message:
-----------
Remove HomeTestCase and AddressBookHomeTestCase, which are no longer being used.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/test/test_calendarquery.py
    CalendarServer/trunk/twistedcaldav/test/util.py

Modified: CalendarServer/trunk/twistedcaldav/test/test_calendarquery.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_calendarquery.py	2014-05-07 18:11:33 UTC (rev 13453)
+++ CalendarServer/trunk/twistedcaldav/test/test_calendarquery.py	2014-05-07 18:22:18 UTC (rev 13454)
@@ -41,10 +41,10 @@
 @inlineCallbacks
 def addEventsDir(testCase, eventsDir, uri):
     """
-    Add events to a L{HomeTestCase} from a directory.
+    Add events to a L{twistedcaldav.test.util.TestCase} from a directory.
 
     @param testCase: The test case to add events to.
-    @type testCase: L{HomeTestCase}
+    @type testCase: L{twistedcaldav.test.util.TestCase}
 
     @param eventsDir: A directory full of events.
     @type eventsDir: L{FilePath}

Modified: CalendarServer/trunk/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/util.py	2014-05-07 18:11:33 UTC (rev 13453)
+++ CalendarServer/trunk/twistedcaldav/test/util.py	2014-05-07 18:22:18 UTC (rev 13454)
@@ -39,7 +39,7 @@
 from txdav.common.datastore.file import CommonDataStore
 from txdav.common.datastore.test.util import deriveQuota, CommonCommonTests
 from txdav.who.util import directoryFromConfig
-from txdav.xml import element as davxml, element
+from txdav.xml import element as element
 from txweb2.dav.test.util import SimpleRequest
 import txweb2.dav.test.util
 from txweb2.http import HTTPError, StatusResponse
@@ -432,162 +432,6 @@
 
 
 
-class HomeTestCase(TestCase):
-    """
-    Utility class for tests which wish to interact with a calendar home rather
-    than a top-level resource hierarchy.
-    """
-
-    def createDataStore(self):
-        # FIXME: AddressBookHomeTestCase needs the same treatment.
-        fp = FilePath(self.mktemp())
-        fp.createDirectory()
-        return CommonDataStore(fp, None, None, True, False)
-
-
-    def setUp(self):
-        """
-        Replace self.site.resource with an appropriately provisioned
-        L{CalendarHomeResource}, and, if the data store backing this test is a
-        file store, replace C{self.docroot} with a path pointing at the path
-        that stores the data for that L{CalendarHomeResource}.
-        """
-        super(HomeTestCase, self).setUp()
-
-
-        @self.directoryFixture.whenDirectoryServiceChanges
-        def addHomeProvisioner(ds):
-            self.homeProvisioner = DirectoryCalendarHomeProvisioningResource(
-                ds, "/calendars/", self.createDataStore()
-            )
-
-        def _defer(user):
-            # Commit the transaction
-            self.addCleanup(self.noRenderCommit)
-            # FIXME: nothing should use docroot any more.
-            aPath = getattr(user._newStoreHome, "_path", None)
-            if aPath is not None:
-                self.docroot = aPath.path
-
-        return self._refreshRoot().addCallback(_defer)
-
-    committed = True
-
-    def noRenderCommit(self):
-        """
-        A resource was retrieved but will not be rendered, so commit.
-        """
-        if not self.committed:
-            self.committed = True
-            return self.site.resource._associatedTransaction.commit()
-
-
-    @inlineCallbacks
-    def _refreshRoot(self, request=None):
-        """
-        Refresh the user resource positioned at the root of this site, to give
-        it a new transaction.
-        """
-        yield self.noRenderCommit()
-        if request is None:
-            request = norequest()
-        users = yield self.homeProvisioner.getChild("users")
-
-        user, ignored = (yield users.locateChild(request, ["wsanchez"]))
-
-        # Force the request to succeed regardless of the implementation of
-        # accessControlList.
-        user.accessControlList = lambda request, *a, **k: succeed(
-            self.grantInherit(davxml.All())
-        )
-
-        # Fix the site to point directly at the user's calendar home so that we
-        # can focus on testing just that rather than hierarchy traversal..
-        self.site.resource = user
-        self.committed = False
-        returnValue(user)
-
-
-    @inlineCallbacks
-    def send(self, request, callback=None):
-        """
-        Override C{send} in order to refresh the 'user' resource each time, to
-        get a new transaction to associate with the calendar home.
-        """
-        yield self.noRenderCommit()
-        yield self._refreshRoot(request)
-        result = (yield super(HomeTestCase, self).send(request))
-        self.committed = True
-        yield self._refreshRoot()
-        if callback is not None:
-            result = yield callback(result)
-        returnValue(result)
-
-
-
-class AddressBookHomeTestCase(TestCase):
-    """
-    Utility class for tests which wish to interact with a addressbook home rather
-    than a top-level resource hierarchy.
-    """
-
-    def setUp(self):
-        """
-        Replace self.site.resource with an appropriately provisioned
-        AddressBookHomeFile, and replace self.docroot with a path pointing at that
-        file.
-        """
-        super(AddressBookHomeTestCase, self).setUp()
-
-
-        @self.directoryFixture.whenDirectoryServiceChanges
-        def addHomeProvisioner(ds):
-            self.homeProvisioner = DirectoryAddressBookHomeProvisioningResource(
-                ds, "/calendars/", self.createDataStore()
-            )
-
-        @inlineCallbacks
-        def _defer(user):
-            # Commit the transaction
-            yield self.site.resource._associatedTransaction.commit()
-            self.docroot = user._newStoreHome._path.path
-
-        return self._refreshRoot().addCallback(_defer)
-
-
-    @inlineCallbacks
-    def _refreshRoot(self):
-        """
-        Refresh the user resource positioned at the root of this site, to give
-        it a new transaction.
-        """
-        users = self.homeProvisioner.getChild("users")
-        user, ignored = (yield users.locateChild(norequest(), ["wsanchez"]))
-
-        # Force the request to succeed regardless of the implementation of
-        # accessControlList.
-        user.accessControlList = lambda request, *a, **k: succeed(
-            self.grantInherit(davxml.All())
-        )
-
-        # Fix the site to point directly at the user's calendar home so that we
-        # can focus on testing just that rather than hierarchy traversal..
-        self.site.resource = user
-        returnValue(user)
-
-
-    @inlineCallbacks
-    def send(self, request, callback=None):
-        """
-        Override C{send} in order to refresh the 'user' resource each time, to
-        get a new transaction to associate with the calendar home.
-        """
-        yield self._refreshRoot()
-        result = (yield super(AddressBookHomeTestCase, self).send(request, callback))
-        returnValue(result)
-
-
-
 class InMemoryPropertyStore(object):
     def __init__(self):
         class _FauxPath(object):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140507/5f8ee179/attachment-0001.html>


More information about the calendarserver-changes mailing list