#NEWLINE# def _create_test_db( self , verbosity = 1 , autoclobber = False ) : #NEWLINE# #INDENT# TEST_NAME = self . _test_database_name ( ) #NEWLINE# TEST_USER = self . _test_database_user ( ) #NEWLINE# TEST_PASSWD = self . _test_database_passwd ( ) #NEWLINE# TEST_TBLSPACE = self . _test_database_tblspace ( ) #NEWLINE# TEST_TBLSPACE_TMP = self . _test_database_tblspace_tmp ( ) #NEWLINE# parameters = { #NEWLINE# #INDENT# 'dbname' : TEST_NAME , #NEWLINE# 'user' : TEST_USER , #NEWLINE# 'password' : TEST_PASSWD , #NEWLINE# 'tblspace' : TEST_TBLSPACE , #NEWLINE# 'tblspace_temp' : TEST_TBLSPACE_TMP , #NEWLINE# #UNINDENT# } #NEWLINE# cursor = self . connection . cursor ( ) #NEWLINE# if self . _test_database_create ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . _execute_test_db_creation ( cursor , parameters , verbosity ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# sys . stderr . write ( ( 'Got an error creating the test database: %s\n' % e ) ) #NEWLINE# if ( not autoclobber ) : #NEWLINE# #INDENT# confirm = input ( ( "It appears the test database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % TEST_NAME ) ) #NEWLINE# #UNINDENT# if ( autoclobber or ( confirm == 'yes' ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( verbosity >= 1 ) : #NEWLINE# #INDENT# print ( ( "Destroying old test database '%s'..." % self . connection . alias ) ) #NEWLINE# #UNINDENT# self . _execute_test_db_destruction ( cursor , parameters , verbosity ) #NEWLINE# self . _execute_test_db_creation ( cursor , parameters , verbosity ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# sys . stderr . write ( ( 'Got an error recreating the test database: %s\n' % e ) ) #NEWLINE# sys . exit ( 2 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# print ( 'Tests cancelled.' ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . _test_user_create ( ) : #NEWLINE# #INDENT# if ( verbosity >= 1 ) : #NEWLINE# #INDENT# print ( 'Creating test user...' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . _create_test_user ( cursor , parameters , verbosity ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# sys . stderr . write ( ( 'Got an error creating the test user: %s\n' % e ) ) #NEWLINE# if ( not autoclobber ) : #NEWLINE# #INDENT# confirm = input ( ( "It appears the test user, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % TEST_USER ) ) #NEWLINE# #UNINDENT# if ( autoclobber or ( confirm == 'yes' ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( verbosity >= 1 ) : #NEWLINE# #INDENT# print ( 'Destroying old test user...' ) #NEWLINE# #UNINDENT# self . _destroy_test_user ( cursor , parameters , verbosity ) #NEWLINE# if ( verbosity >= 1 ) : #NEWLINE# #INDENT# print ( 'Creating test user...' ) #NEWLINE# #UNINDENT# self . _create_test_user ( cursor , parameters , verbosity ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# sys . stderr . write ( ( 'Got an error recreating the test user: %s\n' % e ) ) #NEWLINE# sys . exit ( 2 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# print ( 'Tests cancelled.' ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . connection . settings_dict [ 'SAVED_USER' ] = self . connection . settings_dict [ 'USER' ] #NEWLINE# self . connection . settings_dict [ 'SAVED_PASSWORD' ] = self . connection . settings_dict [ 'PASSWORD' ] #NEWLINE# self . connection . settings_dict [ 'TEST_USER' ] = self . connection . settings_dict [ 'USER' ] = TEST_USER #NEWLINE# self . connection . settings_dict [ 'PASSWORD' ] = TEST_PASSWD #NEWLINE# return self . connection . settings_dict [ 'NAME' ]