Commit caf58da5 authored by Julien Muchembled's avatar Julien Muchembled

tests: do not setup MySQL db if only BTree will be used

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2806 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 39c61963
...@@ -238,6 +238,7 @@ class NEOCluster(object): ...@@ -238,6 +238,7 @@ class NEOCluster(object):
): ):
if not adapter: if not adapter:
adapter = 'MySQL' adapter = 'MySQL'
self.adapter = adapter
self.zodb_storage_list = [] self.zodb_storage_list = []
self.cleanup_on_delete = cleanup_on_delete self.cleanup_on_delete = cleanup_on_delete
self.verbose = verbose self.verbose = verbose
...@@ -324,17 +325,22 @@ class NEOCluster(object): ...@@ -324,17 +325,22 @@ class NEOCluster(object):
return MySQLdb.Connect(**connect_arg_dict) return MySQLdb.Connect(**connect_arg_dict)
def setupDB(self): def setupDB(self):
sql_connection = self.__getSuperSQLConnection() if self.adapter == 'MySQL':
cursor = sql_connection.cursor() sql_connection = self.__getSuperSQLConnection()
for database in self.db_list: cursor = sql_connection.cursor()
cursor.execute('DROP DATABASE IF EXISTS `%s`' % (database, )) for database in self.db_list:
cursor.execute('CREATE DATABASE `%s`' % (database, )) try:
cursor.execute('GRANT ALL ON `%s`.* TO "%s"@"localhost" '\ cursor.execute('DROP DATABASE `%s`' % database)
'IDENTIFIED BY "%s"' % (database, self.db_user, except MySQLdb.OperationalError, (code, _):
self.db_password)) if code != MySQLdb.constants.ER.DB_DROP_EXISTS:
cursor.close() raise
sql_connection.commit() cursor.execute('CREATE DATABASE `%s`' % database)
sql_connection.close() cursor.execute('GRANT ALL ON `%s`.* TO "%s"@"localhost" '
'IDENTIFIED BY "%s"' % (database, self.db_user,
self.db_password))
cursor.close()
sql_connection.commit()
sql_connection.close()
def switchTables(self, database): def switchTables(self, database):
sql_connection = self.__getSuperSQLConnection() sql_connection = self.__getSuperSQLConnection()
......
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