[Zope3-checkins] SVN: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/ Factor out the fixtures so we can reuse them elsewhere.

Martijn Pieters mj at zopatista.com
Sat Oct 9 14:25:39 EDT 2004


Log message for revision 27871:
  Factor out the fixtures so we can reuse them elsewhere.
  


Changed:
  U   Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/test_propfind.py
  A   Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/unitfixtures.py


-=-
Modified: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/test_propfind.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/test_propfind.py	2004-10-09 18:22:55 UTC (rev 27870)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/test_propfind.py	2004-10-09 18:25:39 UTC (rev 27871)
@@ -31,10 +31,8 @@
 
 from zope.app.traversing.api import traverse
 from zope.publisher.browser import TestRequest
-from zope.app.filerepresentation.interfaces import IWriteFile
 from zope.app.site.tests.placefulsetup import PlacefulSetup
 from zope.app.traversing.browser import AbsoluteURL
-from zope.app.container.interfaces import IReadContainer
 from zope.app.dublincore.interfaces import IZopeDublinCore
 from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
 from zope.app.annotation.interfaces import IAnnotatable, IAnnotations
@@ -46,49 +44,11 @@
 from zope.app.dav.interfaces import IDAVWidget
 from zope.app.dav.widget import TextDAVWidget, SequenceDAVWidget
 
+from zope.app.dav.tests.unitfixtures import File, Folder, FooZPT
+
 import zope.app.location
 
-class Folder(zope.app.location.Location):
 
-    implements(IReadContainer)
-
-    def __init__(self, name, level=0, parent=None):
-        self.name = self.__name__ = name
-        self.level=level
-        self.__parent__ = parent
-
-    def items(self):
-        if self.level == 2:
-            return (('last', File('last', 'text/plain', 'blablabla', self)),)
-        result = []
-        for i in range(1, 3):
-            result.append((str(i),
-                           File(str(i), 'text/plain', 'blablabla', self)))
-        result.append(('sub1',
-                       Folder('sub1', level=self.level+1, parent=self)))
-        return tuple(result)
-
-class File(zope.app.location.Location):
-
-    implements(IWriteFile)
-
-    def __init__(self, name, content_type, data, parent=None):
-        self.name = self.__name__ = name
-        self.content_type = content_type
-        self.data = data
-        self.__parent__ = parent
-
-    def write(self, data):
-        self.data = data
-
-class FooZPT(zope.app.location.Location):
-
-    implements(IAnnotatable)
-
-    def getSource(self):
-        return 'bla bla bla'
-
-
 def _createRequest(body=None, headers=None, skip_headers=None):
     if body is None:
         body = '''<?xml version="1.0"  ?>

Added: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/unitfixtures.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/unitfixtures.py	2004-10-09 18:22:55 UTC (rev 27870)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/unitfixtures.py	2004-10-09 18:25:39 UTC (rev 27871)
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# Copyright (c) 2003 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Reusable test fictures for WebDAV tests
+
+$Id: test_propfind.py 27574 2004-09-17 16:15:46Z srichter $
+"""
+__docformat__ = 'restructuredtext'
+
+from zope.interface import implements
+
+from zope.app.filerepresentation.interfaces import IWriteFile
+from zope.app.container.interfaces import IReadContainer
+from zope.app.annotation.interfaces import IAnnotatable
+
+import zope.app.location
+
+class Folder(zope.app.location.Location):
+
+    implements(IReadContainer)
+
+    def __init__(self, name, level=0, parent=None):
+        self.name = self.__name__ = name
+        self.level=level
+        self.__parent__ = parent
+
+    def items(self):
+        if self.level == 2:
+            return (('last', File('last', 'text/plain', 'blablabla', self)),)
+        result = []
+        for i in range(1, 3):
+            result.append((str(i),
+                           File(str(i), 'text/plain', 'blablabla', self)))
+        result.append(('sub1',
+                       Folder('sub1', level=self.level+1, parent=self)))
+        return tuple(result)
+
+class File(zope.app.location.Location):
+
+    implements(IWriteFile)
+
+    def __init__(self, name, content_type, data, parent=None):
+        self.name = self.__name__ = name
+        self.content_type = content_type
+        self.data = data
+        self.__parent__ = parent
+
+    def write(self, data):
+        self.data = data
+
+class FooZPT(zope.app.location.Location):
+
+    implements(IAnnotatable)
+
+    def getSource(self):
+        return 'bla bla bla'
+
+



More information about the Zope3-Checkins mailing list