[Zope-CVS] CVS: Products/Ape/lib/apelib/tests -
testzope2fs.py:1.6.2.4
Shane Hathaway
shane at zope.com
Sat Feb 28 14:58:07 EST 2004
Update of /cvs-repository/Products/Ape/lib/apelib/tests
In directory cvs.zope.org:/tmp/cvs-serv29358/tests
Modified Files:
Tag: ape-fs-oid-branch
testzope2fs.py
Log Message:
Test that Ape doesn't clobber databases with no root.
Instead, it should create the root on opening.
=== Products/Ape/lib/apelib/tests/testzope2fs.py 1.6.2.3 => 1.6.2.4 ===
--- Products/Ape/lib/apelib/tests/testzope2fs.py:1.6.2.3 Thu Feb 26 10:02:46 2004
+++ Products/Ape/lib/apelib/tests/testzope2fs.py Sat Feb 28 14:58:06 2004
@@ -633,8 +633,7 @@
def testWriteToRoot(self):
# Verify it's possible to write to the _root object as well as
# the Application object without either one stomping on each
- # other's data. This is a functional test of
- # apelib.fs.structure.RootDirectoryItems.
+ # other's data.
conn = self.db.open()
conn2 = None
try:
@@ -658,7 +657,8 @@
def testOpenExisting(self):
- # Verifies that opening an existing database finds the same data.
+ # Verifies that opening an existing database finds the same
+ # data.
conn = self.db.open()
try:
app = conn.root()['Application']
@@ -667,7 +667,8 @@
finally:
conn.close()
- # Close the database and open a new one.
+ # Close the database and open a new one pointing at the same
+ # directory.
self.db.close()
self.db = None
self.db, self.conn = self.openDatabase()
@@ -676,6 +677,42 @@
root = conn.root()
app = root['Application']
self.assertEqual(app.test_attribute, '123')
+ finally:
+ conn.close()
+
+
+ def testNoClobberOnOpen(self):
+ # Opening a database with no "_root" shouldn't clobber the
+ # existing contents.
+ conn = self.db.open()
+ try:
+ app = conn.root()['Application']
+ f = Folder()
+ f.id = 'bar'
+ app._setObject(f.id, f)
+ get_transaction().commit()
+ finally:
+ conn.close()
+ self.db.close()
+ self.db = None
+
+ # Destroy the _root and the annotations at the app root.
+ basepath = self.conn.basepath
+ root_p = os.path.join(basepath, '_root')
+ if os.path.exists(root_p):
+ rmtree(root_p)
+ paths = self.conn.afs.getAnnotationPaths(basepath)
+ for path in paths:
+ if os.path.exists(path):
+ os.remove(path)
+
+ # Now look for the 'bar' folder.
+ self.db, self.conn = self.openDatabase()
+ conn = self.db.open()
+ try:
+ root = conn.root()
+ app = root['Application']
+ self.assertEqual(app.bar.id, 'bar')
finally:
conn.close()
More information about the Zope-CVS
mailing list