[Checkins] SVN: zope.webdav/trunk/src/zope/webdav/ Use a zcml defined test layer to configure the functional tests.

Michael Kerrin michael.kerrin at openapp.biz
Sat Feb 3 14:16:55 EST 2007


Log message for revision 72354:
  Use a zcml defined test layer to configure the functional tests.
  
  This results in a big cleanup of the tests.
  

Changed:
  U   zope.webdav/trunk/src/zope/webdav/SETUP.cfg
  D   zope.webdav/trunk/src/zope/webdav/ftesting.zcml
  U   zope.webdav/trunk/src/zope/webdav/ftests/dav.py
  A   zope.webdav/trunk/src/zope/webdav/ftests/ftesting-locking.zcml
  A   zope.webdav/trunk/src/zope/webdav/ftests/ftesting.zcml
  U   zope.webdav/trunk/src/zope/webdav/ftests/test_copymove.py
  U   zope.webdav/trunk/src/zope/webdav/ftests/test_mkcol.py
  U   zope.webdav/trunk/src/zope/webdav/ftests/test_propfind.py
  U   zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py
  U   zope.webdav/trunk/src/zope/webdav/ftests/test_z3_locking.py
  D   zope.webdav/trunk/src/zope/webdav/zope.webdav-ftesting.zcml

-=-
Modified: zope.webdav/trunk/src/zope/webdav/SETUP.cfg
===================================================================
--- zope.webdav/trunk/src/zope/webdav/SETUP.cfg	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/SETUP.cfg	2007-02-03 19:16:54 UTC (rev 72354)
@@ -2,5 +2,4 @@
 
 <data-files zopeskel/etc/package-includes>
   zope.webdav-configure.zcml
-  zope.webdav-ftesting.zcml
 </data-files>

Deleted: zope.webdav/trunk/src/zope/webdav/ftesting.zcml
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftesting.zcml	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/ftesting.zcml	2007-02-03 19:16:54 UTC (rev 72354)
@@ -1,42 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope">
-
-  <class class=".ftests.dav.CollectionResource">
-    <require
-       permission="zope.View"
-       interface=".ftests.dav.ICollectionResource"
-       />
-    <require
-       permission="zope.ManageContent"
-       set_schema=".ftests.dav.ICollectionResource"
-       />
-  </class>
-
-  <class class=".ftests.dav.Resource">
-    <require
-       permission="zope.View"
-       interface=".ftests.dav.IResource"
-       />
-    <require
-       permission="zope.ManageContent"
-       set_schema=".ftests.dav.IResource"
-       />
-  </class>
-
-  <class class=".ftests.dav.EmptyCollectionResource">
-    <require
-       permission="zope.View"
-       interface="zope.app.container.interfaces.IReadContainer" 
-       />
-    <require
-       permission="zope.ManageContent"
-       interface="zope.app.container.interfaces.IWriteContainer"
-       />
-  </class>
-
-  <adapter
-     for=".ftests.dav.EmptyCollectionResource"
-     provides="zope.filerepresentation.interfaces.IWriteDirectory"
-     factory=".ftests.dav.EmptyWriteDirectory"
-     />
-
-</configure>

Modified: zope.webdav/trunk/src/zope/webdav/ftests/dav.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/dav.py	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/ftests/dav.py	2007-02-03 19:16:54 UTC (rev 72354)
@@ -20,30 +20,34 @@
 """
 
 from cStringIO import StringIO
+import os.path
 from BTrees.OOBTree import OOBTree
 
-import persistent
 import transaction
 
 from zope import interface
 from zope import component
 from zope import schema
-from zope.app.testing.functional import HTTPTestCase, FunctionalTestSetup
+import zope.app.testing.functional
+
 from zope.security.proxy import removeSecurityProxy
 from zope.app.folder.folder import Folder
-import zope.app.folder.interfaces
 from zope.app.file.file import File
 from zope.app.publication.http import HTTPPublication
 from zope.security.management import newInteraction, endInteraction
 from zope.security.testing import Principal, Participation
+from zope.dublincore.interfaces import IWriteZopeDublinCore
 
-import zope.webdav.interfaces
 from zope.webdav.publisher import WebDAVRequest
 from zope.webdav.properties import DAVProperty
-import zope.webdav.coreproperties
 from zope.etree.interfaces import IEtree
 from zope.webdav.tests.utils import TestMultiStatusBody
 
+here = os.path.dirname(os.path.realpath(__file__))
+WebDAVLayer = zope.app.testing.functional.ZCMLLayer(
+    os.path.join(here, "ftesting.zcml"), __name__, "WebDAVLayer")
+
+
 class IExamplePropertyStorage(interface.Interface):
 
     exampleintprop = schema.Int(
@@ -59,6 +63,7 @@
 
 exampleTextProperty = DAVProperty("{DAVtest:}exampletextprop",
                                   IExamplePropertyStorage)
+exampleTextProperty.restricted = True
 
 
 ANNOT_KEY = "EXAMPLE_PROPERTY"
@@ -116,167 +121,11 @@
             self.xmlDataSource[0][0].append(elem)
 
 
-class EmptyCollectionResource(Folder):
-    """This collection doesn't contain any subitems
-    """
-    pass
+class DAVTestCase(zope.app.testing.functional.HTTPTestCase,
+                  TestMultiStatusBody):
 
+    layer = WebDAVLayer
 
-def EmptyWriteDirectory(context):
-    return None
-
-class ICollectionResource(zope.app.folder.interfaces.IFolder):
-
-    title = schema.TextLine(
-        title = u"Title",
-        description = u"Title of resource")
-
-
-class CollectionResource(Folder):
-    interface.implements(ICollectionResource)
-
-    title = None
-
-
-class IResource(interface.Interface):
-    """ """
-
-    title = schema.TextLine(
-        title = u"Title",
-        description = u"Title of resource")
-
-    content = schema.Bytes(
-        title = u"Content",
-        description = u"Content of the resource")
-
-class Resource(persistent.Persistent):
-    interface.implements(IResource)
-
-    title = None
-
-    content = None
-
-
-class DisplayNameStorageAdapter(object):
-    interface.implements(zope.webdav.coreproperties.IDAVDisplayname)
-
-    def __init__(self, context, request):
-        self.context = context
-
-    @apply
-    def displayname():
-        def get(self):
-            return self.context.title
-        def set(self, value):
-            self.context.title = value
-        return property(get, set)
-
-
-class GETContentLength(object):
-    component.adapts(IResource, zope.webdav.interfaces.IWebDAVRequest)
-    interface.implements(zope.webdav.coreproperties.IDAVGetcontentlength)
-
-    def __init__(self, context, request):
-        self.context = context
-
-    @property
-    def getcontentlength(self):
-        return len(self.context.content)
-
-
-class DeadProperties(object):
-    interface.implements(zope.webdav.interfaces.IOpaquePropertyStorage)
-
-    def __init__(self, context):
-        self.context = context
-        # This is only a test so aren't that concerned with security at this
-        # point.
-        self.annots = getattr(removeSecurityProxy(self.context), "annots", None)
-
-    def getAllProperties(self):
-        if self.annots is not None:
-            for tag in self.annots:
-                yield tag
-
-    def hasProperty(self, tag):
-        if self.annots is not None and tag in self.annots:
-            return True
-        return False
-
-    def getProperty(self, tag):
-        if self.annots is not None:
-            return self.annots.get(tag, None)
-        return None
-
-    def setProperty(self, tag, value):
-        if self.annots is None:
-            self.annots = removeSecurityProxy(self.context).annots = OOBTree()
-        self.annots[tag] = value
-
-    def removeProperty(self, tag):
-        del self.annots[tag]
-
-
-class DAVTestCase(HTTPTestCase, TestMultiStatusBody):
-
-    def setUp(self):
-        super(DAVTestCase, self).setUp()
-
-        gsm = component.getGlobalSiteManager()
-
-        gsm.registerUtility(exampleIntProperty,
-                            name = "{DAVtest:}exampleintprop",
-                            provided = zope.webdav.interfaces.IDAVProperty)
-        gsm.registerUtility(exampleTextProperty,
-                            name = "{DAVtest:}exampletextprop",
-                            provided = zope.webdav.interfaces.IDAVProperty)
-        # this is to test the include and restricted allprop PROPFIND tests.
-        exampleTextProperty.restricted = False
-
-        gsm.registerAdapter(DisplayNameStorageAdapter,
-                            (IResource, zope.webdav.interfaces.IWebDAVRequest))
-        gsm.registerAdapter(DisplayNameStorageAdapter,
-                            (ICollectionResource,
-                             zope.webdav.interfaces.IWebDAVRequest))
-        gsm.registerAdapter(GETContentLength)
-
-        gsm.registerAdapter(DeadProperties, (IResource,))
-        gsm.registerAdapter(DeadProperties, (ICollectionResource,))
-
-        gsm.registerAdapter(ExamplePropertyStorage,
-                            (IResource, zope.webdav.interfaces.IWebDAVRequest),
-                            provided = IExamplePropertyStorage)
-
-    def tearDown(self):
-        gsm = component.getGlobalSiteManager()
-
-        gsm.unregisterUtility(exampleIntProperty,
-                              name = "{DAVtest:}exampleintprop",
-                              provided = zope.webdav.interfaces.IDAVProperty)
-        gsm.unregisterUtility(exampleTextProperty,
-                              name = "{DAVtest:}exampletextprop",
-                              provided = zope.webdav.interfaces.IDAVProperty)
-
-        gsm.unregisterAdapter(DisplayNameStorageAdapter,
-                            (IResource, zope.webdav.interfaces.IWebDAVRequest))
-        gsm.unregisterAdapter(DisplayNameStorageAdapter,
-                              (ICollectionResource,
-                               zope.webdav.interfaces.IWebDAVRequest))
-        gsm.unregisterAdapter(GETContentLength)
-
-        gsm.unregisterAdapter(DeadProperties, (IResource,))
-        gsm.unregisterAdapter(DeadProperties, (ICollectionResource,))
-
-        gsm.unregisterAdapter(ExamplePropertyStorage,
-                              (IResource,
-                               zope.webdav.interfaces.IWebDAVRequest),
-                              provided = IExamplePropertyStorage)
-
-        super(DAVTestCase, self).tearDown()
-
-        # logout just to make sure.
-        self.logout()
-
     def login(self, principalid = "mgr"):
         """Some locking methods new an interaction in order to lock a resource
         """
@@ -301,7 +150,7 @@
             try:
                 collection = collection[id]
             except KeyError:
-                collection[id] = CollectionResource()
+                collection[id] = Folder()
                 collection = collection[id]
         return collection, path[-1]
 
@@ -311,21 +160,18 @@
         transaction.commit()
         return collection[id]
 
-    def addResource(self, path, content, title = None):
-        resource = Resource()
-        resource.content = content
-        resource.title = title
+    def addResource(self, path, content, title = None, contentType = ''):
+        resource = File(data = content, contentType = contentType)
+        if title is not None:
+            IWriteZopeDublinCore(resource).title = title
         return self.createObject(path, resource)
 
     def addCollection(self, path, title = None):
-        coll = CollectionResource()
-        coll.title = title
+        coll = Folder()
+        if title is not None:
+            IWriteZopeDublinCore(coll).title = title
         return self.createObject(path, coll)
 
-    def addFile(self, path, content, contentType):
-        resource = File(content, contentType)
-        return self.createObject(path, resource)
-
     def createCollectionResourceStructure(self):
         """  _____ rootFolder/ _____
             /          \            \
@@ -345,9 +191,9 @@
                    /        \
                    r2       r3
         """
-        self.addFile("/r1", "first resource", "test/plain")
-        self.addFile("/a/r2", "second resource", "text/plain")
-        self.addFile("/a/r3", "third resource", "text/plain")
+        self.addResource("/r1", "first resource", contentType = "test/plain")
+        self.addResource("/a/r2", "second resource", contentType = "text/plain")
+        self.addResource("/a/r3", "third resource", contentType = "text/plain")
         self.createObject("/b", Folder())
 
     #
@@ -368,7 +214,7 @@
                 instream = instream.getvalue()
             environment["CONTENT_LENGTH"] = len(instream)
 
-        app = FunctionalTestSetup().getApplication()
+        app = zope.app.testing.functional.FunctionalTestSetup().getApplication()
         request = app._request(path, instream, environment = environment,
                                basic = basic, form = form,
                                request = WebDAVRequest,

Added: zope.webdav/trunk/src/zope/webdav/ftests/ftesting-locking.zcml
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/ftesting-locking.zcml	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/ftests/ftesting-locking.zcml	2007-02-03 19:16:54 UTC (rev 72354)
@@ -0,0 +1,8 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <include package="zope.webdav.ftests" file="ftesting.zcml" />
+
+  <include package="zope.app.keyreference" />
+  <include package="zope.locking" />
+
+</configure>


Property changes on: zope.webdav/trunk/src/zope/webdav/ftests/ftesting-locking.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zope.webdav/trunk/src/zope/webdav/ftests/ftesting.zcml
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/ftesting.zcml	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/ftests/ftesting.zcml	2007-02-03 19:16:54 UTC (rev 72354)
@@ -0,0 +1,86 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:zcml="http://namespaces.zope.org/zcml"
+           i18n_domain="zope">
+
+  <include zcml:condition="installed zope.app.zcmlfiles"
+           package="zope.app.zcmlfiles" />
+  <include zcml:condition="not-installed zope.app.zcmlfiles"
+           package="zope.app.zcmlfiles" />
+
+  <include package="zope.app.securitypolicy" file="meta.zcml" />
+  <include package="zope.app.securitypolicy" />
+
+  <securityPolicy
+     component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy"
+     />
+
+  <role
+     id="zope.Anonymous"
+     title="Everybody"
+     description="All users have this role implicitly"
+     />
+
+  <unauthenticatedPrincipal id="zope.anybody" title="Unauthenticated User" />
+  <grant
+     permission="zope.View"
+     role="zope.Anonymous"
+     />
+  <grant
+     permission="zope.app.dublincore.view"
+     role="zope.Anonymous"
+     />
+
+  <role
+     id="zope.Manager"
+     title="Site Manager"
+     />
+
+  <principal id="zope.mgr" title="Manager" login="mgr" password="mgrpw" />
+  <grant
+     role="zope.Manager"
+     principal="zope.mgr"
+     />
+
+  <grantAll role="zope.Manager" />
+
+  <include package="zope.app.authentication" />
+
+  <include package="zope.webdav" />
+  <utility
+     factory="zope.etree.etree.EtreeEtree"
+     />
+
+  <include package="zope.app.folder" />
+  <include package="zope.app.file" />
+  <include package="zope.annotation" />
+  <include package="zope.dublincore" />
+
+  <!--
+      Some random bits.
+    -->
+  <utility
+     name="{DAVtest:}unauthprop"
+     component="zope.webdav.tests.test_proppatch.unauthProperty"
+     />
+  <adapter
+     factory="zope.webdav.tests.test_proppatch.UnauthorizedPropertyStorage"
+     for="zope.interface.Interface
+          zope.webdav.interfaces.IWebDAVRequest"
+     provides="zope.webdav.tests.test_proppatch.IUnauthorizedPropertyStorage"
+     />
+
+  <utility
+     name="{DAVtest:}exampletextprop"
+     component="zope.webdav.ftests.dav.exampleTextProperty"
+     />
+  <utility
+     name="{DAVtest:}exampleintprop"
+     component="zope.webdav.ftests.dav.exampleIntProperty"
+     />
+  <adapter
+     factory="zope.webdav.ftests.dav.ExamplePropertyStorage"
+     for="zope.interface.Interface
+          zope.webdav.interfaces.IWebDAVRequest"
+     />
+
+</configure>


Property changes on: zope.webdav/trunk/src/zope/webdav/ftests/ftesting.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: zope.webdav/trunk/src/zope/webdav/ftests/test_copymove.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/test_copymove.py	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/ftests/test_copymove.py	2007-02-03 19:16:54 UTC (rev 72354)
@@ -23,7 +23,8 @@
 class COPYTestCase(dav.DAVTestCase):
 
     def test_copy_file(self):
-        file = self.addFile("/sourcefile", "some file content", "text/plain")
+        file = self.addResource("/sourcefile", "some file content",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -40,7 +41,8 @@
                          "some file content")
 
     def test_copy_file_nodest(self):
-        file = self.addFile("/sourcefile", "some file content", "text/plain")
+        file = self.addResource("/sourcefile", "some file content",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -49,8 +51,10 @@
         self.assertEqual(response.getStatus(), 400)
 
     def test_copy_file_default_overwrite(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
-        destfile = self.addFile("/destfile", "some dest file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
+        destfile = self.addResource("/destfile", "some dest file",
+                                    contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -64,8 +68,10 @@
                          "some source file")
 
     def test_copy_file_true_overwrite(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
-        destfile = self.addFile("/destfile", "some dest file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
+        destfile = self.addResource("/destfile", "some dest file",
+                                    contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -80,8 +86,10 @@
                          "some source file")
 
     def test_copy_file_false_overwrite(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
-        destfile = self.addFile("/destfile", "some dest file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
+        destfile = self.addResource("/destfile", "some dest file",
+                                    contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -97,7 +105,8 @@
                          "some source file")
 
     def test_copy_file_to_remove(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -109,7 +118,8 @@
         self.assertEqual(response.getStatus(), 502)
 
     def test_copy_file_no_destparent(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -122,7 +132,8 @@
         self.assertEqual(list(self.getRootFolder().keys()), [u"sourcefile"])
 
     def test_copy_to_same_file(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -136,7 +147,8 @@
                          "some source file")
 
     def test_bad_overwrite(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -168,7 +180,8 @@
     """
 
     def test_move_file(self):
-        file = self.addFile("/sourcefile", "some file content", "text/plain")
+        file = self.addResource("/sourcefile", "some file content",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -184,7 +197,8 @@
         self.assert_("sourcefile" not in self.getRootFolder().keys())
 
     def test_move_file_nodest(self):
-        file = self.addFile("/sourcefile", "some file content", "text/plain")
+        file = self.addResource("/sourcefile", "some file content",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -193,8 +207,10 @@
         self.assertEqual(response.getStatus(), 400)
 
     def test_move_file_default_overwrite(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
-        destfile = self.addFile("/destfile", "some dest file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
+        destfile = self.addResource("/destfile", "some dest file",
+                                    contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -207,8 +223,10 @@
         self.assert_("sourcefile" not in self.getRootFolder().keys())
 
     def test_move_file_true_overwrite(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
-        destfile = self.addFile("/destfile", "some dest file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
+        destfile = self.addResource("/destfile", "some dest file",
+                                    contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -222,8 +240,10 @@
         self.assert_("sourcefile" not in self.getRootFolder().keys())
 
     def test_move_file_false_overwrite(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
-        destfile = self.addFile("/destfile", "some dest file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
+        destfile = self.addResource("/destfile", "some dest file",
+                                    contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -239,7 +259,8 @@
                          "some source file")
 
     def test_move_file_to_remove(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -251,7 +272,8 @@
         self.assertEqual(response.getStatus(), 502)
 
     def test_move_file_no_destparent(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -264,7 +286,8 @@
         self.assertEqual(list(self.getRootFolder().keys()), [u"sourcefile"])
 
     def test_move_to_same_file(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -278,7 +301,8 @@
                          "some source file")
 
     def test_bad_overwrite(self):
-        file = self.addFile("/sourcefile", "some source file", "text/plain")
+        file = self.addResource("/sourcefile", "some source file",
+                                contentType = "text/plain")
 
         response = self.publish(
             "/sourcefile", basic = "mgr:mgrpw",
@@ -313,4 +337,3 @@
 
 if __name__ == "__main__":
     unittest.main(defaultTest = "test_suite")
-

Modified: zope.webdav/trunk/src/zope/webdav/ftests/test_mkcol.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/test_mkcol.py	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/ftests/test_mkcol.py	2007-02-03 19:16:54 UTC (rev 72354)
@@ -47,11 +47,6 @@
         self.verifyStatus(path = "/mkcol_test", body = "bla",
                           basic = "mgr:mgrpw", expected = 415)
 
-    def test_mkcol_nowritedir(self):
-        self.createObject("/foo", dav.EmptyCollectionResource())
-        self.verifyStatus(path = "/foo/mkcol_test", body = "",
-                          basic = "mgr:mgrpw", expected = 403)
-
     def verifyStatus(self, path, body, basic, expected = 201):
         clen = len(body)
         result = self.publish(path, basic, env = {"REQUEST_METHOD":"MKCOL",

Modified: zope.webdav/trunk/src/zope/webdav/ftests/test_propfind.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/test_propfind.py	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/ftests/test_propfind.py	2007-02-03 19:16:54 UTC (rev 72354)
@@ -25,32 +25,8 @@
 from zope import component
 import zope.webdav.interfaces
 
-from zope.webdav.tests.test_proppatch import unauthProperty, \
-     UnauthorizedPropertyStorage, IUnauthorizedPropertyStorage
-
 class PROPFINDTests(dav.DAVTestCase):
 
-    def setUp(self):
-        super(PROPFINDTests, self).setUp()
-
-        gsm = component.getGlobalSiteManager()
-        gsm.registerUtility(unauthProperty, name = "{DAVtest:}unauthprop")
-        unauthProperty.restricted = True
-        gsm.registerAdapter(UnauthorizedPropertyStorage,
-                            (dav.IResource,
-                             zope.webdav.interfaces.IWebDAVRequest),
-                            provided = IUnauthorizedPropertyStorage)
-
-    def tearDown(self):
-        super(PROPFINDTests, self).tearDown()
-
-        gsm = component.getGlobalSiteManager()
-        gsm.unregisterUtility(unauthProperty, name = "{DAVtest:}unauthprop")
-        gsm.unregisterAdapter(UnauthorizedPropertyStorage,
-                              (dav.IResource,
-                               zope.webdav.interfaces.IWebDAVRequest),
-                              provided = IUnauthorizedPropertyStorage)
-
     def test_badcontent(self):
         response = self.publish("/", env = {"REQUEST_METHOD": "PROPFIND"},
                                 request_body = "some content",
@@ -112,7 +88,7 @@
         self.assertEqual(len(propel[0]), 1)
         self.assertEqual(propel[0][0].tag, "{DAV:}collection")
 
-    def test_propnames(self):
+    def test_propnames_on_collection(self):
         collection = self.addCollection("/coll")
         
         httpresponse, xmlbody = self.checkPropfind(
@@ -130,7 +106,9 @@
         propel = props[0]
 
         self.assertMSPropertyValue(response, "{DAV:}resourcetype")
+        self.assertMSPropertyValue(response, "{DAV:}creationdate")
         self.assertMSPropertyValue(response, "{DAV:}displayname")
+        self.assertMSPropertyValue(response, "{DAV:}getlastmodified")
 
     def test_propnames_on_resource(self):
         self.addResource("/r1", "some content")
@@ -150,10 +128,13 @@
 
         ## See README.txt for a list of properties defined for these tests.
         self.assertMSPropertyValue(response, "{DAV:}resourcetype")
+        self.assertMSPropertyValue(response, "{DAV:}creationdate")
         self.assertMSPropertyValue(response, "{DAV:}displayname")
-        self.assertMSPropertyValue(response, "{DAVtest:}exampletextprop")
+        self.assertMSPropertyValue(response, "{DAV:}getlastmodified")
+        self.assertMSPropertyValue(response, "{DAV:}getcontenttype")
         self.assertMSPropertyValue(response, "{DAV:}getcontentlength")
-        self.assertMSPropertyValue(response, "{DAVtest:}exampleintprop")
+        self.assertMSPropertyValue(response, "{DAV:}getcontentlanguage")
+        self.assertMSPropertyValue(response, "{DAV:}getetag")
 
     def test_allprop(self):
         collection = self.addCollection("/coll", title = u"Test Collection")
@@ -195,13 +176,15 @@
 
         ## See README.txt for a list of properties defined for these tests.
         self.assertMSPropertyValue(response, "{DAV:}resourcetype")
+        self.assertMSPropertyValue(response, "{DAV:}creationdate")
         self.assertMSPropertyValue(response, "{DAV:}displayname",
                                    text_value = "Test Resource")
-        self.assertMSPropertyValue(response, "{DAVtest:}exampletextprop")
-        self.assertMSPropertyValue(response, "{DAVtest:}exampleintprop",
-                                   text_value = "0")
+        self.assertMSPropertyValue(response, "{DAV:}getlastmodified")
+        self.assertMSPropertyValue(response, "{DAV:}getcontenttype")
         self.assertMSPropertyValue(response, "{DAV:}getcontentlength",
                                    text_value = "21")
+        self.assertMSPropertyValue(response, "{DAV:}getcontentlanguage")
+        self.assertMSPropertyValue(response, "{DAV:}getetag")
 
     def test_allprop_by_default(self):
         self.addCollection("/coll")
@@ -225,7 +208,7 @@
         self.assertMSPropertyValue(response, "{DAV:}displayname")
 
     def test_nobody_propfind(self):
-        self.addCollection("/coll", title = "Test Collection")
+        self.addCollection("/coll", title = u"Test Collection")
         
         httpresponse, xmlbody = self.checkPropfind("/coll",
                                                    env = {"DEPTH": "0"})
@@ -316,7 +299,7 @@
 
     def test_opaque_properties(self):
         file = self.addResource("/r", "some file content",
-                                title = "Test resource")
+                                title = u"Test resource")
 
         opaqueProperties = zope.webdav.interfaces.IOpaquePropertyStorage(file)
         opaqueProperties.setProperty(
@@ -350,7 +333,7 @@
 
     def test_allprop_with_opaque_properties(self):
         file = self.addResource("/r", "some file content",
-                                title = "Test Resource")
+                                title = u"Test Resource")
 
         opaqueProperties = zope.webdav.interfaces.IOpaquePropertyStorage(file)
         opaqueProperties.setProperty(
@@ -380,7 +363,7 @@
                                    text_value = teststr)
 
     def test_allprop_with_deadprops(self):
-        file = self.addResource("/r", "some content", title = "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
         opaqueProperties = zope.webdav.interfaces.IOpaquePropertyStorage(file)
         opaqueProperties.setProperty("{deadprop:}deadprop",
@@ -401,7 +384,7 @@
 This is a dead property.""")
 
     def test_allprop_with_restricted(self):
-        file = self.addResource("/r", "some content", title = "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
         examplePropStorage = component.getMultiAdapter(
             (file, dav.TestWebDAVRequest()), dav.IExamplePropertyStorage)
@@ -416,25 +399,6 @@
         self.assertEqual(len(hrefs), 1)
         self.assertEqual(hrefs[0].text, "http://localhost/r")
 
-        responses = xmlbody.findall("{DAV:}response")
-        self.assertEqual(len(responses), 1)
-        response = responses[0]
-
-        self.assertMSPropertyValue(response, "{DAVtest:}exampletextprop",
-                                   text_value = "EXAMPLE TEXT PROP")
-
-        textprop = component.getUtility(zope.webdav.interfaces.IDAVProperty,
-                                        name = "{DAVtest:}exampletextprop")
-        textprop.restricted = True
-
-        httpresponse, xmlbody = self.checkPropfind(
-            "/r", env = {"DEPTH": "0", "CONTENT_TYPE": "application/xml"},
-            properties = "<D:allprop />")
-
-        hrefs = xmlbody.findall("{DAV:}response/{DAV:}href")
-        self.assertEqual(len(hrefs), 1)
-        self.assertEqual(hrefs[0].text, "http://localhost/r")
-
         props = xmlbody.findall("{DAV:}response/{DAV:}propstat/{DAV:}prop")
         self.assertEqual(len(props), 1) # only one prop element
 
@@ -443,7 +407,7 @@
                          [])
 
     def test_allprop_with_include(self):
-        file = self.addResource("/r", "some content", title = "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
         examplePropStorage = component.getMultiAdapter(
             (file, dav.TestWebDAVRequest()), dav.IExamplePropertyStorage)
@@ -474,7 +438,7 @@
                                    text_value = "EXAMPLE TEXT PROP")
 
     def test_allprop_with_include_on_unauthorized(self):
-        file = self.addResource("/r", "some content", title = "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
         body = """<?xml version="1.0" encoding="utf-8" ?>
 <propfind xmlns:D="DAV:" xmlns="DAV:">
@@ -509,7 +473,8 @@
                                    status = 401)
 
     def test_propfind_onfile(self):
-        self.addFile("/testfile", "some file content", "text/plain")
+        self.addResource("/testfile", "some file content",
+                         contentType = "text/plain")
         httpresponse, xmlbody = self.checkPropfind(
             "/testfile", env = {"DEPTH": "0"}, properties = "<D:allprop />")
 

Modified: zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py	2007-02-03 19:16:54 UTC (rev 72354)
@@ -21,7 +21,7 @@
 import transaction
 
 from zope import component
-from zope.security.interfaces import Unauthorized
+from zope.dublincore.interfaces import IZopeDublinCore
 
 import dav
 
@@ -55,10 +55,8 @@
         self.assertEqual(response.getBody(), "")
 
     def test_setdisplayname_unauthorized(self):
-        file = self.addResource("/r", "some content", "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
-        self.assertEqual(self.getRootFolder()["r"].title, "Test Resource")
-
         body = """<?xml version="1.0" encoding="utf-8" ?>
 <D:propertyupdate xmlns:D="DAV:" xmlns="DAV:">
   <D:set><D:prop>
@@ -77,10 +75,8 @@
 
     def test_setdisplayname(self):
         set_properties = "<D:displayname>Test File</D:displayname>"
-        file = self.addResource("/r", "some content", "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
-        self.assertEqual(self.getRootFolder()["r"].title, "Test Resource")
-
         httpresponse, xmlbody = self.checkProppatch(
             "/r", basic = "mgr:mgrpw", set_properties = set_properties)
 
@@ -90,11 +86,13 @@
 
         self.assertMSPropertyValue(response, "{DAV:}displayname")
 
-        self.assertEqual(self.getRootFolder()["r"].title, u"Test File")
+        title = IZopeDublinCore(self.getRootFolder()["r"]).title
+        self.assertEqual(title, u"Test File")
 
     def test_readonly_property(self):
         set_properties = "<D:getcontentlength>10</D:getcontentlength>"
-        file = self.addResource("/r", "some file content", "Test Resource")
+        file = self.addResource("/r", "some file content",
+                                title = u"Test Resource")
 
         httpresponse, xmlbody = self.checkProppatch(
             "/r", basic = "mgr:mgrpw", set_properties = set_properties)
@@ -190,7 +188,8 @@
 Jim Whitehead
 </Z:Author>
         """
-        file = self.addResource("/r", "some content", "Test Resource")
+        file = self.addResource("/r", "some content",
+                                title = u"Test Resource")
 
         httpresponse, xmlbody = self.checkProppatch(
             "/r", basic = "mgr:mgrpw", set_properties = set_properties)
@@ -211,7 +210,7 @@
 <E:prop3 xmlns:E="example:">PROP0</E:prop3>
         """
 
-        file = self.addResource("/r", "some content", "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
         httpresponse, xmlbody = self.checkProppatch(
             "/r", basic = "mgr:mgrpw", set_properties = set_properties)
@@ -225,10 +224,8 @@
     def test_unicode_title(self):
         teststr = u"copyright \xa9 me"
         set_properties = "<D:displayname>%s</D:displayname>" % teststr
-        file = self.addResource("/r", "some content", "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
-        self.assertEqual(file.title, "Test Resource")
-
         httpresponse, xmlbody = self.checkProppatch(
             "/r", basic = "mgr:mgrpw", set_properties = set_properties)
 
@@ -239,7 +236,7 @@
         self.assertMSPropertyValue(response, "{DAV:}displayname")
 
     def test_remove_live_prop(self):
-        file = self.addResource("/r", "some content", "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
         opaqueProperties = zope.webdav.interfaces.IOpaquePropertyStorage(file)
         opaqueProperties.setProperty("{deadprop:}deadprop",
@@ -274,7 +271,7 @@
 
     def test_remove_dead_prop(self):
         proptag = "{deadprop:}deadprop"
-        file = self.addResource("/r", "some content", "Test Resource")
+        file = self.addResource("/r", "some content", title = u"Test Resource")
 
         opaqueProperties = zope.webdav.interfaces.IOpaquePropertyStorage(file)
         opaqueProperties.setProperty(proptag,
@@ -298,7 +295,7 @@
     def test_setting_unicode_title(self):
         teststr = u"copyright \xa9 me"
         file = self.addResource(u"/" + teststr, "some file content",
-                                title = "Old title")
+                                title = u"Old title")
 
         httpresponse, xmlbody = self.checkProppatch(
             "/" + teststr.encode("utf-8"), basic = "mgr:mgrpw",
@@ -309,8 +306,8 @@
         response = responses[0]
 
         self.assertMSPropertyValue(response, "{DAV:}displayname")
-        resource = self.getRootFolder()[teststr]
-        self.assertEqual(resource.title, teststr)
+        resourcetitle = IZopeDublinCore(self.getRootFolder()[teststr]).title
+        self.assertEqual(resourcetitle, teststr)
 
 
 def test_suite():

Modified: zope.webdav/trunk/src/zope/webdav/ftests/test_z3_locking.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/test_z3_locking.py	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/ftests/test_z3_locking.py	2007-02-03 19:16:54 UTC (rev 72354)
@@ -21,6 +21,7 @@
 import datetime
 import transaction
 from cStringIO import StringIO
+import os.path
 
 import zope.webdav.ftests.dav
 
@@ -38,17 +39,24 @@
 from zope.etree.interfaces import IEtree
 from zope.etree.testing import assertXMLEqual
 
+here = os.path.dirname(os.path.realpath(__file__))
+WebDAVLockingLayer = zope.app.testing.functional.ZCMLLayer(
+    os.path.join(here, "ftesting-locking.zcml"), __name__, "WebDAVLockingLayer")
+
+
 class LOCKNotAllowedTestCase(zope.webdav.ftests.dav.DAVTestCase):
 
+    layer = WebDAVLockingLayer
+
     def test_lock_file(self):
-        file = self.addFile("/testfilenotallowed",
-                            "some file content", "text/plain")
+        file = self.addResource("/testfilenotallowed", "some file content",
+                                contentType = "text/plain")
         self.assertRaises(MethodNotAllowed, self.publish,
             "/testfilenotallowed", basic = "mgr:mgrpw")
 
     def test_options(self):
-        file = self.addFile("/testfilenotallowed",
-                            "some file content", "text/plain")
+        file = self.addResource("/testfilenotallowed", "some file content",
+                                contentType = "text/plain")
         response = self.publish("/testfilenotallowed", basic = "mgr:mgrpw",
                                 handle_errors = True)
 
@@ -58,7 +66,8 @@
         self.assert_("UNLOCK" not in allowed)
 
     def test_lockingprops_noutility(self):
-        self.addFile("/testfile", "some file content", "text/plain")
+        self.addResource("/testfile", "some file content",
+                         contentType = "text/plain")
 
         httpresponse, xmlbody = self.checkPropfind(
             "/testfile", env = {"DEPTH": "0"},
@@ -79,6 +88,8 @@
 
 class LOCKTestCase(zope.webdav.ftests.dav.DAVTestCase):
 
+    layer = WebDAVLockingLayer
+
     def _setup(self):
         zope.webdav.ftests.dav.DAVTestCase.setUp(self)
 
@@ -112,8 +123,8 @@
         del self.utility
 
     def test_options(self):
-        file = self.addFile("/testfilenotallowed",
-                            "some file content", "text/plain")
+        file = self.addResource("/testfilenotallowed", "some file content",
+                                contentType = "text/plain")
         response = self.publish("/testfilenotallowed", basic = "mgr:mgrpw",
                                 handle_errors = True)
 
@@ -123,7 +134,8 @@
         self.assert_("UNLOCK" in allowed)
 
     def test_lock_file_unauthorized(self):
-        file = self.addFile("/testfile", "some file content", "text/plain")
+        file = self.addResource("/testfile", "some file content",
+                                contentType = "text/plain")
 
         lockmanager = IDAVLockmanager(file)
         self.assertEqual(lockmanager.islocked(), False)
@@ -161,7 +173,8 @@
         self.assertEqual(response.getStatus(), 422)
 
     def test_lock_file(self):
-        file = self.addFile("/testfile", "some file content", "text/plain")
+        file = self.addResource("/testfile", "some file content",
+                                contentType = "text/plain")
 
         lockmanager = IDAVLockmanager(file)
         self.assertEqual(lockmanager.islocked(), False)
@@ -212,8 +225,8 @@
         self.assertEqual(lockmanager.islocked(), True)
 
     def test_already_exclusive_locked_file(self):
-        file = self.addFile("/testlockedfile",
-                            "some file content", "text/plain")
+        file = self.addResource("/testlockedfile", "some file content",
+                                contentType = "text/plain")
 
         token = tokens.ExclusiveLock(file, "mgr")
         token.duration = datetime.timedelta(seconds = 100)
@@ -501,8 +514,8 @@
             lockmanager.getActivelock().locktoken[0], locktoken[1:-1])
 
     def test_lock_invalid_depth(self):
-        file = self.addResource("/testresource",
-                                "some file content", "Test Resource")
+        file = self.addResource("/testresource", "some file content",
+                                title = u"Test Resource")
 
         body ="""<?xml version="1.0" encoding="utf-8" ?>
 <D:lockinfo xmlns:D='DAV:'>
@@ -563,7 +576,7 @@
     def test_invalid_lock_request_uri(self):
         self.login()
         file = self.addResource("/testresource", "some file content",
-                                "Test Resource")
+                                title = u"Test Resource")
 
         lockmanager = IDAVLockmanager(file)
         lockmanager.lock(u"exclusive", u"write", u"Michael",
@@ -582,7 +595,7 @@
     def test_no_lock_request_uri(self):
         self.login()
         file = self.addResource("/testresource", "some file content",
-                                "Test Resource")
+                                title = u"Test Resource")
 
         lockmanager = IDAVLockmanager(file)
         lockmanager.lock(u"exclusive", u"write", u"Michael",
@@ -599,7 +612,7 @@
 
     def test_not_locked_resource(self):
         file = self.addResource("/testresource", "some file content",
-                                "Test Resource")
+                                title = u"Test Resource")
 
         response = self.publish("/testresource", basic = "mgr:mgrpw",
                                 env = {"REQUEST_METHOD": "LOCK",
@@ -612,6 +625,8 @@
 
 class UNLOCKTestCase(zope.webdav.ftests.dav.DAVTestCase):
 
+    layer = WebDAVLockingLayer
+
     def setUp(self):
         super(UNLOCKTestCase, self).setUp()
 
@@ -626,7 +641,8 @@
 
     def test_unlock_file(self):
         self.login()
-        file = self.addFile("/testfile", "some file content", "text/plain")
+        file = self.addResource("/testfile", "some file content",
+                                contentType = "text/plain")
 
         lockmanager = IDAVLockmanager(file)
         self.assertEqual(lockmanager.islocked(), False)
@@ -657,7 +673,8 @@
 
     def test_unlock_file_bad_token(self):
         self.login()
-        file = self.addFile("/testfile", "some file content", "text/plain")
+        file = self.addResource("/testfile", "some file content",
+                                contentType = "text/plain")
 
         lockmanager = IDAVLockmanager(file)
         self.assertEqual(lockmanager.islocked(), False)
@@ -690,7 +707,8 @@
 
     def test_unlock_file_no_token(self):
         self.login()
-        file = self.addFile("/testfile", "some file content", "text/plain")
+        file = self.addResource("/testfile", "some file content",
+                                contentType = "text/plain")
 
         lockmanager = IDAVLockmanager(file)
         self.assertEqual(lockmanager.islocked(), False)
@@ -759,7 +777,8 @@
         self.assertEqual(lockmanager.islocked(), False)
 
     def test_supportedlock_prop(self):
-        file = self.addFile("/testfile", "some file content", "text/plain")
+        file = self.addResource("/testfile", "some file content",
+                                contentType = "text/plain")
         httpresponse, xmlbody = self.checkPropfind(
             "/testfile", properties = "<D:prop><D:supportedlock /></D:prop>")
 

Deleted: zope.webdav/trunk/src/zope/webdav/zope.webdav-ftesting.zcml
===================================================================
--- zope.webdav/trunk/src/zope/webdav/zope.webdav-ftesting.zcml	2007-02-03 18:02:53 UTC (rev 72353)
+++ zope.webdav/trunk/src/zope/webdav/zope.webdav-ftesting.zcml	2007-02-03 19:16:54 UTC (rev 72354)
@@ -1 +0,0 @@
-<include package="zope.webdav" file="ftesting.zcml" />



More information about the Checkins mailing list