[CalendarServer-changes] [5220] CalendarServer/trunk/calendarserver/provision/test/test_root.py

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 25 22:42:14 PST 2010


Revision: 5220
          http://trac.macosforge.org/projects/calendarserver/changeset/5220
Author:   glyph at apple.com
Date:     2010-02-25 22:42:14 -0800 (Thu, 25 Feb 2010)
Log Message:
-----------
Test for OPTIONS response in CardDAV mode.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/provision/test/test_root.py

Modified: CalendarServer/trunk/calendarserver/provision/test/test_root.py
===================================================================
--- CalendarServer/trunk/calendarserver/provision/test/test_root.py	2010-02-26 05:40:57 UTC (rev 5219)
+++ CalendarServer/trunk/calendarserver/provision/test/test_root.py	2010-02-26 06:42:14 UTC (rev 5220)
@@ -17,7 +17,8 @@
 import os
 
 from twisted.cred.portal import Portal
-from twisted.internet.defer import inlineCallbacks, maybeDeferred
+from twisted.internet.defer import inlineCallbacks, maybeDeferred, returnValue
+
 from twext.web2 import http_headers
 from twext.web2 import responsecode
 from twext.web2 import server
@@ -34,6 +35,7 @@
 from twistedcaldav.directory.test.test_xmlfile import xmlFile, augmentsFile
 
 from calendarserver.provision.root import RootResource
+from twistedcaldav.config import config
 from twistedcaldav.directory import augment
 
 class FakeCheckSACL(object):
@@ -54,6 +56,12 @@
     def setUp(self):
         super(RootTests, self).setUp()
 
+        # XXX make sure that the config hooks have been run, so that we get the
+        # default RootResourceACL key is set and traversal works.  This is not
+        # great, and the ACLs supported by the root resource should really be
+        # an _attribute_ on the root resource. -glyph
+        config.update({})
+
         self.docroot = self.mktemp()
         os.mkdir(self.docroot)
 
@@ -81,6 +89,41 @@
 
         self.site = server.Site(self.root)
 
+
+
+class ComplianceTests(RootTests):
+    """
+    Tests to verify CalDAV compliance of the root resource.
+    """
+
+    @inlineCallbacks
+    def issueRequest(self, segments, method='GET'):
+        """
+        Get a resource from a particular path from the root URI, and return a
+        Deferred which will fire with (something adaptable to) an HTTP response
+        object.
+        """
+        request = SimpleRequest(self.site, method, ('/'.join([''] + segments)))
+        rsrc = self.root
+        while segments:
+            rsrc, segments = (yield maybeDeferred(rsrc.locateChild, request, segments))
+
+        result = yield rsrc.renderHTTP(request)
+        returnValue(result)
+
+
+    @inlineCallbacks
+    def test_optionsIncludeCalendar(self):
+        """
+        OPTIONS request should include a DAV header that mentions the
+        addressbook capability.
+        """
+        self.patch(config, 'EnableCardDAV', True)
+        response = yield self.issueRequest([''], 'OPTIONS')
+        self.assertIn('addressbook', response.headers.getHeader('DAV'))
+
+
+
 class SACLTests(RootTests):
     
     @inlineCallbacks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100225/f2b96a69/attachment.html>


More information about the calendarserver-changes mailing list