Commit 05364754 authored by Yusei Tahara's avatar Yusei Tahara

Add a test for the bug #20110628-ABAA76.

parent ffd66c63
...@@ -1076,6 +1076,54 @@ class TestZodbPropertySheet(ERP5TypeTestCase): ...@@ -1076,6 +1076,54 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
self.test_module.setTitle, self.test_module.setTitle,
'my_property_type_validity_constraint_title') 'my_property_type_validity_constraint_title')
def testConstraintAfterClosingZODBConnection(self):
"""
Make sure that constraint works even if ZODB connection close.
This test is added for the bug #20110628-ABAA76.
"""
# Open new connection and add a new constraint.
db = self.app._p_jar.db()
con = db.open()
app = con.root()['Application'].__of__(self.app.aq_parent)
portal = app[self.getPortalName()]
from Products.ERP5.ERP5Site import getSite, setSite
old_site = getSite()
setSite(portal)
import erp5
dummy = getattr(erp5.portal_type, 'TALES Constraint')(id='dummy')
portal.portal_property_sheets.TestMigration._setObject('dummy', dummy)
dummy = portal.portal_property_sheets.TestMigration.dummy
dummy.edit(reference='test_dummy_constraint',
expression='python: object.getTitle() == "my_tales_constraint_title"')
dummy.Predicate_view()
transaction.commit()
# Recreate class with a newly added constraint
synchronizeDynamicModules(portal, force=True)
# Load test_module
test_module = getattr(portal, 'Test Migration')
test_module.objectValues()
# Then close this new connection.
transaction.abort()
con.close()
# Delete all connections by force
# This code depends on ZODB implementation.
for i in db.pool.available[:]:
if i[1] == con:
db.pool.available.remove(i)
db.pool.all.remove(con)
del con
# Back to the default connection.
transaction.abort()
self.app._p_jar._resetCache()
setSite(old_site)
# Call checkConsistency and make sure that ConnectionStateError does not occur.
self.assert_(self.test_module.checkConsistency())
def testAddEmptyProperty(self): def testAddEmptyProperty(self):
""" """
When users create properties in a PropertySheet, the property is When users create properties in a PropertySheet, the property is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment