[CalendarServer-changes] [5997] CalendarServer/branches/users/glyph/sql-store/twistedcaldav/test/ util.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri Aug 6 10:39:38 PDT 2010
Revision: 5997
http://trac.macosforge.org/projects/calendarserver/changeset/5997
Author: glyph at apple.com
Date: 2010-08-06 10:39:37 -0700 (Fri, 06 Aug 2010)
Log Message:
-----------
hook for store creation
Modified Paths:
--------------
CalendarServer/branches/users/glyph/sql-store/twistedcaldav/test/util.py
Modified: CalendarServer/branches/users/glyph/sql-store/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/twistedcaldav/test/util.py 2010-08-06 17:39:23 UTC (rev 5996)
+++ CalendarServer/branches/users/glyph/sql-store/twistedcaldav/test/util.py 2010-08-06 17:39:37 UTC (rev 5997)
@@ -15,18 +15,12 @@
##
from __future__ import with_statement
-from calendarserver.provision.root import RootResource
-__all__ = [
- "featureUnimplemented",
- "testUnimplemented",
- "todo",
- "TestCase",
-]
-
import os
import xattr
+from calendarserver.provision.root import RootResource
+
from twisted.python.failure import Failure
from twisted.internet.base import DelayedCall
from twisted.internet.defer import succeed, fail, inlineCallbacks, returnValue
@@ -34,7 +28,7 @@
from twisted.internet.protocol import ProcessProtocol
from twext.python.memcacheclient import ClientFactory
-from twext.python.filepath import CachingFilePath as FilePath, CachingFilePath
+from twext.python.filepath import CachingFilePath as FilePath
import twext.web2.dav.test.util
from twext.web2.dav import davxml
from twext.web2.http import HTTPError, StatusResponse
@@ -51,6 +45,13 @@
from txdav.common.datastore.file import CommonDataStore
+
+__all__ = [
+ "featureUnimplemented",
+ "testUnimplemented",
+ "todo",
+ "TestCase",
+]
DelayedCall.debug = True
def _todo(f, why):
@@ -67,6 +68,8 @@
augmentsFile = dirTest.child("augments.xml")
proxiesFile = dirTest.child("proxies.xml")
+
+
class TestCase(twext.web2.dav.test.util.TestCase):
resource_class = RootResource
@@ -96,6 +99,15 @@
)
+ def createDataStore(self):
+ """
+ Create an L{IDataStore} that can store calendars (but not
+ addressbooks.) By default returns a L{CommonDataStore}, but this is a
+ hook for subclasses to override to provide different data stores.
+ """
+ return CommonDataStore(FilePath(config.DocumentRoot), None, True, False)
+
+
def setupCalendars(self):
"""
Set up the resource at /calendars (a L{DirectoryCalendarHomeProvisioningResource}),
@@ -103,7 +115,7 @@
"""
# Need a data store
- _newStore = CommonDataStore(CachingFilePath(config.DocumentRoot), None, True, False)
+ _newStore = self.createDataStore()
self.calendarCollection = DirectoryCalendarHomeProvisioningResource(
self.directoryService,
@@ -133,7 +145,7 @@
config.ConfigRoot = "config"
config.LogRoot = "logs"
config.RunRoot = "logs"
-
+
if not os.path.exists(config.DataRoot):
os.makedirs(config.DataRoot)
if not os.path.exists(config.DocumentRoot):
@@ -150,6 +162,7 @@
config.DirectoryAddressBook.Enabled = False
+
def createHierarchy(self, structure, root=None):
if root is None:
root = self.mktemp()
@@ -295,6 +308,13 @@
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, True, False)
+
+
def setUp(self):
"""
Replace self.site.resource with an appropriately provisioned
@@ -303,13 +323,10 @@
"""
super(HomeTestCase, self).setUp()
- fp = FilePath(self.mktemp())
- fp.createDirectory()
-
self.createStockDirectoryService()
# Need a data store
- _newStore = CommonDataStore(fp, None, True, False)
+ _newStore = self.createDataStore()
self.homeProvisioner = DirectoryCalendarHomeProvisioningResource(
self.directoryService, "/calendars/",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100806/45f93196/attachment.html>
More information about the calendarserver-changes
mailing list