From a34ab976e9b331e92956b3cf141f7d462b85ef5f Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 9 Aug 2021 23:46:04 +0200 Subject: [PATCH] Utilise une seule base. Fixture pour tests unitaires. --- app/scodoc/sco_utils.py | 5 +++-- tests/conftest.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 2f6c828a..85564437 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -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(): diff --git a/tests/conftest.py b/tests/conftest.py index db9efe5e..3e77cf57 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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