Utilise une seule base. Fixture pour tests unitaires.

This commit is contained in:
Emmanuel Viennet 2021-08-09 23:46:04 +02:00
parent 0dbffd6fe0
commit a34ab976e9
2 changed files with 7 additions and 5 deletions

View File

@ -52,7 +52,7 @@ STRING_TYPES = six.string_types
from PIL import Image as PILImage
from flask import g, url_for, request
from flask import g, url_for, request, current_app
from scodoc_manager import sco_mgr
@ -324,7 +324,8 @@ def get_dept_id():
def get_db_cnx_string(scodoc_dept=None):
return "dbname=SCO" + (scodoc_dept or g.scodoc_dept)
return current_app.config["SQLALCHEMY_DATABASE_URI"]
# return "dbname=SCO" + (scodoc_dept or g.scodoc_dept)
def ScoURL():

View File

@ -42,10 +42,11 @@ def test_client():
admin_role = Role.query.filter_by(name="Admin").first()
u.add_role(admin_role, "TEST00")
db.session.add(u)
ndb.set_sco_dept("TEST00") # set db connection
truncate_database() # erase tables
ndb.set_sco_dept("TEST") # set db connection
yield client
# ndb.close_dept_connection()
# Teardown:
db.session.remove()
db.drop_all()
# db.drop_all()
# => laisse la base en état (l'efface au début)
# utile pour les tests en cours de développement