[Zope-CVS] CVS: Products/Ape/lib/apelib/tests - testzope2fs.py:1.4.4.5

Shane Hathaway shane at zope.com
Wed Jan 21 00:21:43 EST 2004


Update of /cvs-repository/Products/Ape/lib/apelib/tests
In directory cvs.zope.org:/tmp/cvs-serv21277/tests

Modified Files:
      Tag: ape-0_8-branch
	testzope2fs.py 
Log Message:
Restructured filesystem connections to make them easier to understand.

- Used the word annotation in place of section, since it's possible to
  plug in other strategies for storing file/directory annotations, and
  'section' doesn't make that clear.

- Separated the file annotation implementation from the filesystem connection
  class, again making it clearer that you can plug in other implementations.

- Moved the exception declaration and cache implementations into other
  modules, reducing the number of modules.


=== Products/Ape/lib/apelib/tests/testzope2fs.py 1.4.4.4 => 1.4.4.5 ===
--- Products/Ape/lib/apelib/tests/testzope2fs.py:1.4.4.4	Thu Dec 25 23:22:34 2003
+++ Products/Ape/lib/apelib/tests/testzope2fs.py	Wed Jan 21 00:21:12 2004
@@ -33,7 +33,7 @@
 from apelib.zodb3.storage import ApeStorage
 from apelib.zodb3.resource import StaticResource
 from apelib.zope2.mapper import loadConf
-from apelib.fs.exceptions import FSWriteError
+from apelib.fs.interfaces import FSWriteError
 from apelib.fs.connection import FSConnection
 from zope2testbase import Zope2TestBase, Folder
 
@@ -71,7 +71,7 @@
         db = ApeDB(storage, resource)
         self.db = db
         get_transaction().begin()
-        self.conn._clearCache()
+        self.conn.afs.clearCache()
 
     def tearDown(self):
         get_transaction().abort()
@@ -99,7 +99,7 @@
             get_transaction().commit()
 
             for folder in (f, f2, f3):
-                text = self.conn.readSection(folder._p_oid, 'classification')
+                text = self.conn.readAnnotation(folder._p_oid, 'classification')
                 self.assert_(text.find('class_name=OFS.Folder.Folder') >= 0)
         finally:
             conn.close()
@@ -156,7 +156,7 @@
             app._setObject(template.id, template, set_owner=0)
             get_transaction().commit()
 
-            dir = self.conn._expandPath('/')
+            dir = self.conn.getPath('/')
             names = os.listdir(dir)
             self.assert_('template.html' in names, names)
             self.assert_('template' not in names, names)
@@ -188,7 +188,7 @@
                     self.assert_(not hasattr(f, 'script%d.py' % n))
                 # white box test: verify the scripts were actually stored
                 # with .py extensions.
-                dir = self.conn._expandPath('/folder')
+                dir = self.conn.getPath('/folder')
                 names = os.listdir(dir)
                 for n in range(3):
                     self.assert_(('script%d.py' % n) in names, names)
@@ -222,7 +222,7 @@
                     self.assert_(not hasattr(f, 'script%d' % n))
                 # white box test: verify the scripts were actually stored
                 # with .py extensions.
-                dir = self.conn._expandPath('/folder')
+                dir = self.conn.getPath('/folder')
                 names = os.listdir(dir)
                 for n in range(3):
                     self.assert_(('script%d.py' % n) in names, names)
@@ -248,7 +248,7 @@
             f._setObject(script.id, script, set_owner=0)
             get_transaction().commit()
 
-            dir = self.conn._expandPath('/folder')
+            dir = self.conn.getPath('/folder')
             names = os.listdir(dir)
             self.assert_(('script0.py') in names, names)
             self.assert_(('script0') not in names, names)
@@ -282,7 +282,7 @@
             f._setObject(script.id, script, set_owner=0)
             get_transaction().commit()
 
-            dir = self.conn._expandPath('/folder')
+            dir = self.conn.getPath('/folder')
             names = os.listdir(dir)
             self.assert_(('script0.py') in names, names)
             self.assert_(('script0') in names, names)
@@ -356,7 +356,7 @@
             f._setObject(script.id, script, set_owner=0)
             get_transaction().commit()
 
-            dir = self.conn._expandPath('/folder')
+            dir = self.conn.getPath('/folder')
             names = os.listdir(dir)
             self.assert_(('script0.py') in names, names)
             self.assert_(('script0.dtml') in names, names)
@@ -427,7 +427,7 @@
             finally:
                 conn2.close()
 
-            dir = self.conn._expandPath('/')
+            dir = self.conn.getPath('/')
             names = os.listdir(dir)
             self.assert_(('image.png') in names, names)
             self.assert_(('image') not in names, names)
@@ -450,7 +450,7 @@
                            content_type='application/octet-stream')
             get_transaction().commit()
 
-            dir = self.conn._expandPath('/')
+            dir = self.conn.getPath('/')
             names = os.listdir(dir)
             self.assert_(('hello.txt') in names, names)
             self.assert_(('world.dat') in names, names)
@@ -464,7 +464,7 @@
         # Verify Zope chooses the right object type for
         # a new object.
         # White box test.
-        dir = self.conn._expandPath('/')
+        dir = self.conn.getPath('/')
         f = open(os.path.join(dir, 'test.py'), 'wt')
         f.write('return "Ok!"')
         f.close()
@@ -482,12 +482,12 @@
         # Verify that even though the extension gets stripped off
         # in Zope, Zope still sees the object as it should.
         # White box test.
-        dir = self.conn._expandPath('/')
+        dir = self.conn.getPath('/')
         f = open(os.path.join(dir, 'test.py'), 'wt')
         f.write('return "Ok!"')
         f.close()
-        
-        f = open(os.path.join(dir, self.conn.metadata_prefix
+
+        f = open(os.path.join(dir, self.conn.afs.annotation_prefix
                               + 'properties'), 'wt')
         f.write('[object_names]\ntest\n')
         f.close()
@@ -505,7 +505,7 @@
         # Verify Zope uses a File object for unrecognized files on
         # the filesystem.  White box test.
         data = 'data goes here'
-        dir = self.conn._expandPath('/')
+        dir = self.conn.getPath('/')
         f = open(os.path.join(dir, 'test'), 'wt')
         f.write(data)
         f.close()
@@ -522,7 +522,7 @@
     def testDefaultPropertySchema(self):
         # Verify Zope uses the default property schema when no properties
         # are set.
-        dir = self.conn._expandPath('/')
+        dir = self.conn.getPath('/')
         os.mkdir(os.path.join(dir, 'test'))
         conn = self.db.open()
         try:
@@ -558,8 +558,8 @@
                 conn2.close()
 
             # Verify the stowaway is in the remainder file.
-            dir = self.conn._expandPath('/')
-            f = open(os.path.join(dir, self.conn.metadata_prefix
+            dir = self.conn.getPath('/')
+            f = open(os.path.join(dir, self.conn.afs.annotation_prefix
                                   + 'remainder'), 'rb')
             data = f.read()
             f.close()
@@ -588,7 +588,7 @@
     def testGuessFileContentType(self):
         # Verify that file content type guessing happens.
         data = '<html><body>Cool stuff</body></html>'
-        dir = self.conn._expandPath('/')
+        dir = self.conn.getPath('/')
         f = open(os.path.join(dir, 'testobj'), 'wt')
         f.write(data)
         f.close()
@@ -632,7 +632,7 @@
 class Zope2FSUnderscoreTests (Zope2FSTests):
     
     def _createConnections(self, path):
-        conn = FSConnection(path, metadata_prefix='_')
+        conn = FSConnection(path, annotation_prefix='_')
         return {'fs': conn}
 
 




More information about the Zope-CVS mailing list