ajout creation user "bach" pour certains tests

This commit is contained in:
Emmanuel Viennet 2021-08-07 16:32:24 +02:00
parent 383fdb0e53
commit 06f66e6976
2 changed files with 10 additions and 3 deletions

View File

@ -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