Make testing much faster by using a save point, rather than recreating the database every test

This commit is contained in:
Joseph Schorr 2014-01-30 20:57:40 -05:00
parent 31ff854031
commit 0833c88065
6 changed files with 129 additions and 24 deletions

View file

@ -2,6 +2,7 @@ import logging
from app import app as application
import model
logging.basicConfig(**application.config['LOGGING_CONFIG'])
@ -27,6 +28,16 @@ application.register_blueprint(registry, url_prefix='/v1')
application.register_blueprint(api, url_prefix='/api')
application.register_blueprint(webhooks, url_prefix='/webhooks')
def close_db(exc):
db = model.db
if not db.is_closed():
logger.debug('Disconnecting from database.')
db.close()
application.teardown_request(close_db)
# Remove this for prod config
application.debug = True