From 06f66e6976258c7463741e8a62e7b16ad7eecfd8 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 7 Aug 2021 16:32:24 +0200 Subject: [PATCH] ajout creation user "bach" pour certains tests --- tests/conftest.py | 13 ++++++++++--- .../scenarios}/test_scenario1_formation.py | 0 2 files changed, 10 insertions(+), 3 deletions(-) rename {scotests => tests/scenarios}/test_scenario1_formation.py (100%) diff --git a/tests/conftest.py b/tests/conftest.py index 3e7888f0..758250f4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -30,11 +30,18 @@ def test_client(): db.create_all() Role.insert_roles() u = User(user_name="admin") - admin_role = Role.query.filter_by(name="SuperAdmin").first() - u.add_role(admin_role, "TEST00") + super_admin_role = Role.query.filter_by(name="SuperAdmin").first() + u.add_role(super_admin_role, "TEST00") # u.set_password("admin") login_user(u) - # db.session.add(u) + # VĂ©rifie que l'utilisateur bach existe + u = User.query.filter_by(user_name="bach").first() + if u is None: + u = User(user_name="bach") + if not "Admin" in {r.name for r in u.roles}: + 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 yield client diff --git a/scotests/test_scenario1_formation.py b/tests/scenarios/test_scenario1_formation.py similarity index 100% rename from scotests/test_scenario1_formation.py rename to tests/scenarios/test_scenario1_formation.py