[CalendarServer-changes] [6613] CalendarServer/branches/users/glyph/dont-start-postgres/ calendarserver/tap/test/test_caldav.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Nov 10 18:57:21 PST 2010
Revision: 6613
http://trac.macosforge.org/projects/calendarserver/changeset/6613
Author: glyph at apple.com
Date: 2010-11-10 18:57:18 -0800 (Wed, 10 Nov 2010)
Log Message:
-----------
locate site a bit more robustly; make test_caldav pass again.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/test/test_caldav.py
Modified: CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/test/test_caldav.py
===================================================================
--- CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/test/test_caldav.py 2010-11-11 02:57:05 UTC (rev 6612)
+++ CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/test/test_caldav.py 2010-11-11 02:57:18 UTC (rev 6613)
@@ -34,7 +34,7 @@
from twisted.internet.defer import Deferred
from twisted.internet.task import Clock
-from twisted.application.service import IService
+from twisted.application.service import IService, IServiceCollection
from twisted.application import internet
from twext.web2.dav import auth
@@ -114,8 +114,10 @@
if self.processTransports:
return self.processTransports.pop(0)
else:
- print 'wth', self.calls
- raise AssertionError("There were no process transports available.")
+ raise AssertionError(
+ "There were no process transports available. Calls: " +
+ repr(self.calls)
+ )
def spawnProcess(self, processProtocol, executable, args=(), env={},
@@ -310,6 +312,7 @@
"type": "twistedcaldav.directory.augment.AugmentXMLDB"
}
+ self.config.UseDatabase = False
self.config.ServerRoot = self.mktemp()
self.config.ConfigRoot = "config"
self.config.ProcessType = "Single"
@@ -334,16 +337,19 @@
self.writeConfig()
+
def tearDown(self):
config.setDefaults(DEFAULT_CONFIG)
config.reset()
+
def writeConfig(self):
"""
Flush self.config out to self.configFile
"""
writePlist(self.config, self.configFile)
+
def makeService(self):
"""
Create a service by calling into CalDAVServiceMaker with
@@ -353,17 +359,39 @@
return CalDAVServiceMaker().makeService(self.options)
+
def getSite(self):
"""
- Get the server.Site from the service by finding the HTTPFactory
+ Get the server.Site from the service by finding the HTTPFactory.
"""
service = self.makeService()
+ for listeningService in inServiceHierarchy(
+ service,
+ # FIXME: need a better predicate for 'is this really an HTTP
+ # factory' but this works for now.
+ # NOTE: in a database 'single' configuration, PostgresService
+ # will prevent the HTTP services from actually getting added to
+ # the hierarchy until the hierarchy has started.
+ lambda x: hasattr(x, 'args')
+ ):
+ return listeningService.args[1].protocolArgs['requestFactory']
+ raise RuntimeError("No site found.")
- # FIXME: should at least use service name, not index
- return service.getServiceNamed("HTTP").protocolArgs["requestFactory"]
+def inServiceHierarchy(svc, predicate):
+ """
+ Find services in the service collection which satisfy the given predicate.
+ """
+ for subsvc in svc.services:
+ if IServiceCollection.providedBy(subsvc):
+ for value in inServiceHierarchy(subsvc, predicate):
+ yield value
+ if predicate(subsvc):
+ yield subsvc
+
+
def determineAppropriateGroupID():
"""
Determine a secondary group ID which can be used for testing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101110/314f6086/attachment.html>
More information about the calendarserver-changes
mailing list