Commit 08987a17 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Add test for transaction isolation.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1525 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 240922ef
......@@ -122,6 +122,55 @@ class ClientTests(NEOFunctionalTest):
self.assertEqual(o2.value(), 3)
self.assertEqual(o1.value(), 3)
def testIsolationAtZopeLevel(self):
""" Check transaction isolation within zope connection """
self.__setup()
t, c = self.makeTransaction()
c.root()['item'] = 0
t.commit()
t1, c1 = self.makeTransaction()
t2, c2 = self.makeTransaction()
c1.root()['item'] = 1
t1.commit()
# load objet from zope cache
self.assertEqual(c1.root()['item'], 1)
self.assertEqual(c2.root()['item'], 0)
def testIsolationWithoutZopeCache(self):
""" Check isolation with zope cache cleared """
self.__setup()
t, c = self.makeTransaction()
c.root()['item'] = 0
t.commit()
t1, c1 = self.makeTransaction()
t2, c2 = self.makeTransaction()
c1.root()['item'] = 1
t1.commit()
# clear zope cache to force re-ask NEO
c1.cacheMinimize()
c2.cacheMinimize()
self.assertEqual(c1.root()['item'], 1)
self.assertEqual(c2.root()['item'], 0)
def testIsolationWithNewConnection(self):
""" Check isolation with zope cache cleared """
self.__setup()
t, c = self.makeTransaction()
c.root()['item'] = 0
t.commit()
t1, c1 = self.makeTransaction()
t2, c2 = self.makeTransaction()
c1.root()['item'] = 1
t1.commit()
# open a new connection for this transaction
c1 = self.db.open(transaction_manager=t1)
c2 = self.db.open(transaction_manager=t2)
self.assertEqual(c1.root()['item'], 1)
self.assertEqual(c2.root()['item'], 0)
def test_suite():
return unittest.makeSuite(ClientTests)
......
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