nosetest is the default test framework in Turbogeras 2.0. The application has a websetup.py module that initialise the database. I use mysql for my development and production environment and websetup works fine, but nosetest uses sqlite on memory and when it tries to initialise the DB sends an error:
TypeError: SQLite Date, Time, and DateTime types only accept Python datetime objects as input.
I've detected when this happens and is in the import fase:
csvreader = csv.reader(open('res/products.csv'), delimiter=",", quotechar="'")
for row in csvreader:
p = model.Product(row[1], row[2], row[3], row[4] + ".jpg")
# Even tried to convert the date to a sqlalchemy type
# need to put a conditional here, when testing I don't care this date
import sqlalchemy
dateadded = sqlalchemy.types.DateTime(row[5])
p.dateAdded = dateadded
p.brand_id = row[6]
p.code = row[3]
ccat = model.DBSession.query(model.Category)\
.filter(model.Category.id==int(row[8]) + 3).one()
p.categories.append(ccat)
p.normalPrice = row[9]
p.specialPrice = row[10]
p.discountPrice = row[11]
model.DBSession.add(p)
How can I tell when nosetest is running? I've try:
if globals().has_key('ModelTest'):
and
if vars().has_key('ModelTest'):
The first one with no results and the second one with error