Make testing much faster by using a save point, rather than recreating the database every test
This commit is contained in:
parent
31ff854031
commit
0833c88065
6 changed files with 129 additions and 24 deletions
|
@ -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
|
||||
|
||||
|
|
Reference in a new issue