[Zope-Checkins] CVS: ZODB3/ZConfig/tests - testStorage.py:1.5

Barry Warsaw barry@wooz.org
Fri, 22 Nov 2002 16:07:29 -0500


Update of /cvs-repository/ZODB3/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv4901

Modified Files:
	testStorage.py 
Log Message:
tearDown(): Fred reminds us about shutil.rmtree(). :)

testMinimalStorage(): a test similar to testFullStorage


=== ZODB3/ZConfig/tests/testStorage.py 1.4 => 1.5 ===
--- ZODB3/ZConfig/tests/testStorage.py:1.4	Fri Nov 22 15:34:26 2002
+++ ZODB3/ZConfig/tests/testStorage.py	Fri Nov 22 16:07:29 2002
@@ -1,4 +1,5 @@
 import os
+import shutil
 import tempfile
 import unittest
 from StringIO import StringIO
@@ -25,8 +26,7 @@
         try:
             # Full storage creates a directory
             if os.path.isdir(self.tmpfn):
-                # XXX Doesn't work on Window
-                os.system('rm -rf %s' % self.tmpfn)
+                shutil.rmtree(self.tmpfn)
             else:
                 os.remove(self.tmpfn)
         except os.error:
@@ -105,7 +105,6 @@
         try:
             from bsddb3Storage.Full import Full
         except ImportError:
-            print 'ImportError'
             return
         sample = """
         <Storage>
@@ -120,11 +119,39 @@
         storageconf = rootconf.getSection("Storage")
         cls, args = Storage.getStorageInfo(storageconf)
         self.assertEqual(cls, Full)
+        # It's too hard to test the config instance equality
         args = args.copy()
         del args['config']
         self.assertEqual(args, {"name": self.tmpfn})
         self.storage = Storage.createStorage(storageconf)
         self.assert_(isinstance(self.storage, Full))
+        # XXX _config isn't public
+        self.assert_(self.storage._config.cachesize, 1000)
+
+    def testMinimalStorage(self):
+        try:
+            from bsddb3Storage.Minimal import Minimal
+        except ImportError:
+            return
+        sample = """
+        <Storage>
+        type       Minimal
+        name       %s
+        cachesize  1000
+        </Storage>
+        """ % self.tmpfn
+        os.mkdir(self.tmpfn)
+        io = StringIO(sample)
+        rootconf = ZConfig.loadfile(io)
+        storageconf = rootconf.getSection("Storage")
+        cls, args = Storage.getStorageInfo(storageconf)
+        self.assertEqual(cls, Minimal)
+        # It's too hard to test the config instance equality
+        args = args.copy()
+        del args['config']
+        self.assertEqual(args, {"name": self.tmpfn})
+        self.storage = Storage.createStorage(storageconf)
+        self.assert_(isinstance(self.storage, Minimal))
         # XXX _config isn't public
         self.assert_(self.storage._config.cachesize, 1000)