Commit e37f79c2 authored by Vincent Pelletier's avatar Vincent Pelletier

Enable autocommit on SQL connections established in tests.

This makes sure changes made while expecting condition to happen are
visible to that connection.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1603 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 8ba76a4f
...@@ -284,10 +284,12 @@ class NEOCluster(object): ...@@ -284,10 +284,12 @@ class NEOCluster(object):
db = ZODB.DB(storage=self.getZODBStorage()) db = ZODB.DB(storage=self.getZODBStorage())
return (db, db.open()) return (db, db.open())
def getSQLConnection(self, db): def getSQLConnection(self, db, autocommit=False):
assert db in self.db_list assert db in self.db_list
return MySQLdb.Connect(user=self.db_user, passwd=self.db_password, conn = MySQLdb.Connect(user=self.db_user, passwd=self.db_password,
db=db) db=db)
conn.autocommit(autocommit)
return conn
def _getProcessList(self, type): def _getProcessList(self, type):
return self.process_dict.get(type) return self.process_dict.get(type)
......
...@@ -74,7 +74,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -74,7 +74,7 @@ class StorageTests(NEOFunctionalTest):
db.close() db.close()
def __checkDatabase(self, db_name): def __checkDatabase(self, db_name):
db = self.neo.getSQLConnection(db_name) db = self.neo.getSQLConnection(db_name, autocommit=True)
# wait for the sql transaction to be commited # wait for the sql transaction to be commited
def callback(last_try): def callback(last_try):
object_number = self.queryCount(db, 'select count(*) from obj') object_number = self.queryCount(db, 'select count(*) from obj')
...@@ -107,7 +107,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -107,7 +107,7 @@ class StorageTests(NEOFunctionalTest):
self.assertEqual(len(storage_list), 2) self.assertEqual(len(storage_list), 2)
def __checkReplicateCount(self, db_name, target_count, timeout=0, delay=1): def __checkReplicateCount(self, db_name, target_count, timeout=0, delay=1):
db = self.neo.getSQLConnection(db_name) db = self.neo.getSQLConnection(db_name, autocommit=True)
def callback(last_try): def callback(last_try):
replicate_count = self.queryCount(db, replicate_count = self.queryCount(db,
'select count(distinct uuid) from pt') 'select count(distinct uuid) from pt')
......
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