Skip to content

Commit

Permalink
Added necessary functions for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyij committed Feb 26, 2012
1 parent f2cb015 commit e897e04
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
3 changes: 2 additions & 1 deletion base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, cursor):
def execute(self, query, args=None):
try:
query = query.replace ("%s","?")
print args
args = CubridConvert().boolean_field(args)
return self.cursor.execute(query, args)
except Database.IntegrityError, e:
Expand Down Expand Up @@ -196,7 +197,7 @@ def __init__(self, *args, **kwargs):
super(DatabaseWrapper, self).__init__(*args, **kwargs)

self.server_version = None
self.features = DatabaseFeatures()
self.features = DatabaseFeatures(self)
self.ops = DatabaseOperations()
self.client = DatabaseClient(self)
self.creation = DatabaseCreation(self)
Expand Down
14 changes: 8 additions & 6 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"""
class CubridConvert():
def boolean_field(self, args):
args = list(args)
for i, j in enumerate(args):
if j == bool(j):
args[i] = int(j)
args = tuple(args)
return args
if args <> None:
print "replacing bool"
args = list(args)
for i, j in enumerate(args):
if j == bool(j):
args[i] = int(j)
args = tuple(args)
return args


22 changes: 9 additions & 13 deletions creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ def _create_test_db(self, verbosity, autoclobber):

# Create the test database and start the cubrid server.
try:
p = subprocess.Popen(["cubrid", "createdb", "%s" % test_database_name])
ret = os.waitpid(p.pid, 0)[1]
p = subprocess.Popen(["cubrid", "server", "start", "%s" % test_database_name])
ret = os.waitpid(p.pid, 0)[1]

subprocess.call(["cubrid", 'createdb' , '--db-volume-size=20M', '--log-volume-size=20M', "%s" % test_database_name])
print 'Created'
subprocess.call(["cubrid", "server", "start", "%s" % test_database_name])
print 'Started'
except Exception, e:
sys.stderr.write("Got an error creating the test database: %s\n" % e)
if not autoclobber:
Expand All @@ -129,16 +129,12 @@ def _create_test_db(self, verbosity, autoclobber):
try:
if verbosity >= 1:
print "Destroying old test database..."
p = subprocess.Popen(["cubrid", "server", "stop", "%s" % test_database_name])
ret = os.waitpid(p.pid, 0)[1]
p = subprocess.Popen(["cubrid", "deletedb", "%s" % test_database_name])
ret = os.waitpid(p.pid, 0)[1]
subprocess.call(["cubrid", "server", "stop", "%s" % test_database_name])
subprocess.call(["cubrid", "deletedb", "%s" % test_database_name])
if verbosity >= 1:
print "Creating test database..."
p = subprocess.Popen(["cubrid", "createdb", "%s" % test_database_name])
ret = os.waitpid(p.pid, 0)[1]
p = subprocess.Popen(["cubrid", "server", "start", "%s" % test_database_name])
ret = os.waitpid(p.pid, 0)[1]
subprocess.call(["cubrid", 'createdb' , '--db-volume-size=20M', '--log-volume-size=20M', "%s" % test_database_name])
subprocess.call(["cubrid", "server", "start", "%s" % test_database_name])
except Exception, e:
sys.stderr.write("Got an error recreating the test database: %s\n" % e)
sys.exit(2)
Expand Down

0 comments on commit e897e04

Please sign in to comment.