[CalendarServer-changes] [5578] CalendarServer/branches/users/wsanchez/transations/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Sun May 9 15:40:45 PDT 2010
Revision: 5578
http://trac.macosforge.org/projects/calendarserver/changeset/5578
Author: glyph at apple.com
Date: 2010-05-09 15:40:43 -0700 (Sun, 09 May 2010)
Log Message:
-----------
Move xmlFile/augmentsFile/proxiesFile to a more central location so they're easier to import, and add a createStockDirectoryService test utility to make it easier to (safely) use a simple, complete directory service for tests which require one.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/transations/twistedcaldav/directory/test/test_xmlfile.py
CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/util.py
Modified: CalendarServer/branches/users/wsanchez/transations/twistedcaldav/directory/test/test_xmlfile.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/twistedcaldav/directory/test/test_xmlfile.py 2010-05-09 22:37:04 UTC (rev 5577)
+++ CalendarServer/branches/users/wsanchez/transations/twistedcaldav/directory/test/test_xmlfile.py 2010-05-09 22:40:43 UTC (rev 5578)
@@ -18,16 +18,12 @@
from twext.python.filepath import CachingFilePath as FilePath
-from twistedcaldav.test.util import TestCase
from twistedcaldav.directory import augment
from twistedcaldav.directory.directory import DirectoryService
import twistedcaldav.directory.test.util
from twistedcaldav.directory.xmlfile import XMLDirectoryService
+from twistedcaldav.test.util import TestCase, xmlFile, augmentsFile, proxiesFile
-xmlFile = FilePath(os.path.join(os.path.dirname(__file__), "accounts.xml"))
-augmentsFile = FilePath(os.path.join(os.path.dirname(__file__), "augments.xml"))
-proxiesFile = FilePath(os.path.join(os.path.dirname(__file__), "proxies.xml"))
-
# FIXME: Add tests for GUID hooey, once we figure out what that means here
class XMLFileBase(object):
@@ -304,5 +300,10 @@
))
def test_recordTypesSubset(self):
- directory = XMLDirectoryService({'xmlFile' : self.xmlFile(), 'recordTypes' : (DirectoryService.recordType_users, DirectoryService.recordType_groups)}, alwaysStat=True)
+ directory = XMLDirectoryService(
+ {'xmlFile' : self.xmlFile(),
+ 'recordTypes' : (DirectoryService.recordType_users,
+ DirectoryService.recordType_groups)},
+ alwaysStat=True
+ )
self.assertEquals(set(("users", "groups")), set(directory.recordTypes()))
Modified: CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/util.py 2010-05-09 22:37:04 UTC (rev 5577)
+++ CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/util.py 2010-05-09 22:40:43 UTC (rev 5578)
@@ -15,6 +15,9 @@
##
from __future__ import with_statement
+from twistedcaldav.directory.xmlfile import XMLDirectoryService
+from twistedcaldav.directory import augment
+from twext.python.filepath import CachingFilePath as FilePath
__all__ = [
"featureUnimplemented",
@@ -33,6 +36,7 @@
from twisted.internet.protocol import ProcessProtocol
from twext.python.memcacheclient import ClientFactory
+from twext.python.filepath import CachingFilePath as FilePath
import twext.web2.dav.test.util
from twext.web2.http import HTTPError, StatusResponse
@@ -50,9 +54,34 @@
testUnimplemented = lambda f: _todo(f, "Test unimplemented")
todo = lambda why: lambda f: _todo(f, why)
+dirTest = FilePath(__file__).parent().sibling("directory").child("test")
+
+xmlFile = dirTest.child("accounts.xml")
+augmentsFile = dirTest.child("augments.xml")
+proxiesFile = dirTest.sibling("proxies.xml")
+
class TestCase(twext.web2.dav.test.util.TestCase):
resource_class = CalDAVFile
+ def createStockDirectoryService(self):
+ """
+ Create a stock C{directoryService} attribute and assign it.
+ """
+ self.xmlFile = FilePath(config.DataRoot).child("accounts.xml")
+ self.xmlFile.setContent(xmlFile.getContent())
+
+ # *temporarily* set up an augment service so this directory service will
+ # work.
+ self.patch(augment, "AugmentService", augment.AugmentXMLDB(
+ xmlFiles=(augmentsFile.path,)
+ )
+ )
+
+ self.directoryService = XMLDirectoryService(
+ {'xmlFile' : "accounts.xml"}
+ )
+
+
def setUp(self):
super(TestCase, self).setUp()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100509/007561c1/attachment.html>
More information about the calendarserver-changes
mailing list