[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/ZODBMountPoint/
Add one test and expand another for database mounting.
Chris McDonough
chrism at plope.com
Sat Oct 29 16:35:51 EDT 2005
Log message for revision 39719:
Add one test and expand another for database mounting.
Make sure that savepoint creation is optimistic.
Changed:
U Zope/trunk/lib/python/Products/ZODBMountPoint/MountedObject.py
U Zope/trunk/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py
-=-
Modified: Zope/trunk/lib/python/Products/ZODBMountPoint/MountedObject.py
===================================================================
--- Zope/trunk/lib/python/Products/ZODBMountPoint/MountedObject.py 2005-10-29 13:02:57 UTC (rev 39718)
+++ Zope/trunk/lib/python/Products/ZODBMountPoint/MountedObject.py 2005-10-29 20:35:51 UTC (rev 39719)
@@ -82,7 +82,6 @@
container = self._construct(container, part)
return container
-
class CustomTrailblazer (SimpleTrailblazer):
"""Like SimpleTrailblazer but creates custom objects.
@@ -113,7 +112,7 @@
obj = context.unrestrictedTraverse(id)
# Commit a subtransaction to assign the new object to
# the correct database.
- transaction.savepoint()
+ transaction.savepoint(optimistic=True)
return obj
@@ -123,7 +122,8 @@
'''
meta_type = 'ZODB Mount Point'
_isMountedObject = 1
- # DM 2005-05-17: default value change necessary after fix of '_create_mount_point' handling
+ # DM 2005-05-17: default value change necessary after fix of
+ # '_create_mount_point' handling
#_create_mount_points = 0
_create_mount_points = True
@@ -193,7 +193,7 @@
obj = Application()
root[real_root] = obj
# Get it into the database
- transaction.savepoint()
+ transaction.savepoint(optimistic=True)
else:
raise
Modified: Zope/trunk/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py
===================================================================
--- Zope/trunk/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py 2005-10-29 13:02:57 UTC (rev 39718)
+++ Zope/trunk/lib/python/Products/ZODBMountPoint/tests/testMountPoint.py 2005-10-29 20:35:51 UTC (rev 39719)
@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
-"""Tests of DBTab and ZODBMountPoint
+"""Tests of ZODBMountPoint
"""
import os
@@ -23,7 +23,9 @@
from OFS.Application import Application
from OFS.Folder import Folder
import App.config
-from Products.ZODBMountPoint.MountedObject import manage_addMounts, getMountPoint
+from Products.ZODBMountPoint.MountedObject import manage_addMounts
+from Products.ZODBMountPoint.MountedObject import getMountPoint
+from Products.ZODBMountPoint.MountedObject import manage_getMountStatus
from Zope2.Startup.datatypes import DBTab
try:
@@ -62,7 +64,7 @@
original_config = None
-class DBTabTests (unittest.TestCase):
+class MountingTests(unittest.TestCase):
def setUp(self):
global original_config
@@ -88,7 +90,6 @@
App.config.setConfiguration(d)
self.conf = conf
db = conf.getDatabase('/')
- self.db = db
conn = db.open()
root = conn.root()
root['Application'] = app = Application()
@@ -104,7 +105,6 @@
transaction.abort()
self.app._p_jar.close()
del self.app
- del self.db
for db in self.conf.databases.values():
db.close()
del self.conf
@@ -126,6 +126,10 @@
self.assertEqual(app.mount2._p_changed, 0)
self.assertEqual(app._p_changed, 0)
+ self.assertEqual(app.mount1.a1, '1')
+ self.assertEqual(app.mount2.a2, '2')
+ self.assertEqual(app.a3, '3')
+
def testGetMountPoint(self):
self.assert_(getMountPoint(self.app) is None)
self.assert_(getMountPoint(self.app.mount1) is not None)
@@ -139,8 +143,43 @@
transaction.commit()
self.assert_(getMountPoint(self.app.mount2) is None)
+ def test_manage_getMountStatus(self):
+ status = manage_getMountStatus(self.app)
+ expected = [{'status': 'Ok',
+ 'path': '/mount1',
+ 'name': 'test_mount1.fs',
+ 'exists': 1},
+ {'status': 'Ok',
+ 'path': '/mount2',
+ 'name': 'test_mount2.fs',
+ 'exists': 1}]
+ self.assertEqual(expected, status)
+ del self.app.mount2
+ status = manage_getMountStatus(self.app)
+ expected = [{'status': 'Ok',
+ 'path': '/mount1',
+ 'name': 'test_mount1.fs',
+ 'exists': 1},
+ {'status': 'Ready to create',
+ 'path': '/mount2',
+ 'name': 'test_mount2.fs',
+ 'exists': 0}]
+ self.assertEqual(expected, status)
+ self.app.mount2 = Folder('mount2')
+ status = manage_getMountStatus(self.app)
+ expected = [{'status': 'Ok',
+ 'path': '/mount1',
+ 'name': 'test_mount1.fs',
+ 'exists': 1},
+ {'status': '** Something is in the way **',
+ 'path': '/mount2',
+ 'name': 'test_mount2.fs',
+ 'exists': 1}]
+ self.assertEqual(expected, status)
+
+
def test_suite():
- return unittest.makeSuite(DBTabTests, 'test')
+ return unittest.makeSuite(MountingTests, 'test')
if __name__ == '__main__':
unittest.main()
More information about the Zope-Checkins
mailing list