[CalendarServer-changes] [5932] CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 23 13:32:25 PDT 2010


Revision: 5932
          http://trac.macosforge.org/projects/calendarserver/changeset/5932
Author:   cdaboo at apple.com
Date:     2010-07-23 13:32:24 -0700 (Fri, 23 Jul 2010)
Log Message:
-----------
Test fixes.

Modified Paths:
--------------
    CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_accounting.py
    CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_config.py
    CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_extensions.py
    CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_vcardindex.py
    CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/util.py

Modified: CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_accounting.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_accounting.py	2010-07-23 20:14:53 UTC (rev 5931)
+++ CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_accounting.py	2010-07-23 20:32:24 UTC (rev 5932)
@@ -30,7 +30,7 @@
         super(AccountingITIP, self).setUp()
         config.AccountingCategories.iTIP = True
         config.AccountingPrincipals = ["*",]
-        config.AccountingLogRoot = self.mkdtemp("accounting")[0]
+        os.mkdir(config.AccountingLogRoot)
 
     class _Principal(object):
         
@@ -59,7 +59,7 @@
         """
         
         # Make log root a file
-        config.AccountingLogRoot = os.path.abspath(self.mktemp())
+        config.AccountingLogRoot = "other"
         open(config.AccountingLogRoot, "w").close()
         emitAccounting("iTIP", self._Principal("1234-5678"), "bogus")
 
@@ -70,7 +70,6 @@
         super(AccountingHTTP, self).setUp()
         config.AccountingCategories.HTTP = True
         config.AccountingPrincipals = ["*",]
-        config.AccountingLogRoot = self.mkdtemp("accounting")[0]
 
     def test_channel_request(self):
         """

Modified: CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_config.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_config.py	2010-07-23 20:14:53 UTC (rev 5931)
+++ CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_config.py	2010-07-23 20:32:24 UTC (rev 5932)
@@ -18,7 +18,7 @@
 from twext.python.log import logLevelForNamespace
 
 from twistedcaldav.config import config, ConfigDict
-from twistedcaldav.static import CalDAVFile
+from twistedcaldav.resource import CalDAVResource
 from twistedcaldav.stdconfig import DEFAULT_CONFIG, PListConfigProvider,\
     RELATIVE_PATHS
 from twistedcaldav.test.util import TestCase
@@ -241,7 +241,7 @@
         self.assertNotIn("Foo", DEFAULT_CONFIG)
 
     def testComplianceClasses(self):
-        resource = CalDAVFile("/")
+        resource = CalDAVResource()
         
         config.EnableProxyPrincipals = True
         self.assertTrue("calendar-proxy" in resource.davComplianceClasses())

Modified: CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_extensions.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_extensions.py	2010-07-23 20:14:53 UTC (rev 5931)
+++ CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_extensions.py	2010-07-23 20:32:24 UTC (rev 5932)
@@ -164,7 +164,7 @@
         def addUnicodeChild(davFile):
             m = MetaDataMixin()
             m.contentType = lambda: MimeType.fromString('text/plain')
-            m.resourceType = lambda r: succeed(davxml.ResourceType())
+            m.resourceType = lambda: davxml.ResourceType()
             m.isCollection = lambda: False
             davFile.putChild(unicodeChildName, m)
         yield self.doDirectoryTest([nonASCIIFilename], addUnicodeChild,

Modified: CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_vcardindex.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_vcardindex.py	2010-07-23 20:14:53 UTC (rev 5931)
+++ CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/test_vcardindex.py	2010-07-23 20:32:24 UTC (rev 5932)
@@ -24,6 +24,30 @@
 
 import os
 
+class MinimalResourceReplacement(object):
+    """
+    Provide the minimal set of attributes and methods from CalDAVFile required
+    by L{Index}.
+    """
+
+    def __init__(self, filePath):
+        self.fp = filePath
+
+
+    def isAddressBookCollection(self):
+        return True
+
+
+    def getChild(self, name):
+        # FIXME: this should really return something with a child method
+        return self.fp.child(name)
+
+
+    def initSyncToken(self):
+        pass
+
+
+
 class SQLIndexTests (twistedcaldav.test.util.TestCase):
     """
     Test abstract SQL DB class
@@ -32,7 +56,10 @@
     def setUp(self):
         super(SQLIndexTests, self).setUp()
         self.site.resource.isAddressBookCollection = lambda: True
-        self.db = AddressBookIndex(self.site.resource)
+        self.indexDirPath = self.site.resource.fp
+        # FIXME: since this resource lies about isCalendarCollection, it doesn't
+        # have all the associated backend machinery to actually get children.
+        self.db = AddressBookIndex(MinimalResourceReplacement(self.indexDirPath))
 
 
     def test_reserve_uid_ok(self):

Modified: CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/util.py	2010-07-23 20:14:53 UTC (rev 5931)
+++ CalendarServer/branches/new-store-no-caldavfile/twistedcaldav/test/util.py	2010-07-23 20:32:24 UTC (rev 5932)
@@ -36,12 +36,14 @@
 from twext.python.filepath import CachingFilePath as FilePath
 import twext.web2.dav.test.util
 from twext.web2.dav import davxml
+from twext.web2.dav.static import DAVFile
 from twext.web2.http import HTTPError, StatusResponse
 
 from twistedcaldav import memcacher
+from twistedcaldav.bind import doBind
 from twistedcaldav.config import config
-from twistedcaldav.static import CalDAVFile, AddressBookHomeProvisioningFile
 from twistedcaldav.directory import augment
+from twistedcaldav.directory.addressbook import DirectoryAddressBookHomeProvisioningResource
 from twistedcaldav.directory.calendar import DirectoryCalendarHomeProvisioningResource
 from twistedcaldav.directory.principal import (
     DirectoryPrincipalProvisioningResource)
@@ -66,7 +68,7 @@
 proxiesFile = dirTest.child("proxies.xml")
 
 class TestCase(twext.web2.dav.test.util.TestCase):
-    resource_class = CalDAVFile
+    resource_class = DAVFile
 
     def createStockDirectoryService(self):
         """
@@ -115,8 +117,7 @@
         path = self.site.resource.fp.child("addressbooks")
         path.createDirectory()
 
-        self.addressbookCollection = AddressBookHomeProvisioningFile(
-            path,
+        self.addressbookCollection = DirectoryAddressBookHomeProvisioningResource(
             self.directoryService,
             "/addressbooks/",
             _newStore
@@ -127,11 +128,16 @@
     def setUp(self):
         super(TestCase, self).setUp()
 
+        # FIXME: this is only here to workaround circular imports
+        doBind()
+
         config.reset()
         serverroot = self.mktemp()
         os.mkdir(serverroot)
-        config.ServerRoot = serverroot
+        config.ServerRoot = os.path.abspath(serverroot)
         config.ConfigRoot = "config"
+        config.LogRoot = "logs"
+        config.RunRoot = "logs"
         
         if not os.path.exists(config.DataRoot):
             os.makedirs(config.DataRoot)
@@ -139,6 +145,8 @@
             os.makedirs(config.DocumentRoot)
         if not os.path.exists(config.ConfigRoot):
             os.makedirs(config.ConfigRoot)
+        if not os.path.exists(config.LogRoot):
+            os.makedirs(config.LogRoot)
 
         config.Memcached.Pools.Default.ClientEnabled = False
         config.Memcached.Pools.Default.ServerEnabled = False
@@ -370,8 +378,7 @@
         # Need a data store
         _newStore = CommonDataStore(fp, True, False)
 
-        self.homeProvisioner = AddressBookHomeProvisioningFile(
-            os.path.join(fp.path, "addressbooks"),
+        self.homeProvisioner = DirectoryAddressBookHomeProvisioningResource(
             self.directoryService, "/addressbooks/",
             _newStore
         )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100723/0731c596/attachment-0001.html>


More information about the calendarserver-changes mailing list