From 553614be465ae2c2e9c240b8e955f7b2462987e1 Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Tue, 2 Jul 2024 20:46:02 +0100 Subject: [PATCH] test: update auth user creation for fixtures --- src/backend/tests/conftest.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/backend/tests/conftest.py b/src/backend/tests/conftest.py index fd5299be55..be9c3d0820 100644 --- a/src/backend/tests/conftest.py +++ b/src/backend/tests/conftest.py @@ -31,7 +31,7 @@ from sqlalchemy_utils import create_database, database_exists from app.auth.auth_routes import get_or_create_user -from app.auth.osm import AuthUser +from app.auth.auth_schemas import AuthUser, FMTMUser from app.central import central_crud from app.config import settings from app.db.database import Base, get_db @@ -93,15 +93,18 @@ async def admin_user(db): db_user = await get_or_create_user( db, AuthUser( + sub="fmtm|1", username="localadmin", - id=1, role=UserRole.ADMIN, ), ) - # Upgrade role from default MAPPER (if user already exists) - db_user["role"] = UserRole.ADMIN - db.commit() - return db_user + + return FMTMUser( + id=db_user.id, + username=db_user.username, + role=UserRole[db_user.role], + profile_img=db_user.profile_img, + ) @pytest.fixture(scope="function") @@ -174,11 +177,7 @@ async def project(db, admin_user, organisation): db, project_metadata, odkproject["id"], - AuthUser( - username=admin_user["username"], - id=admin_user["id"], - role=UserRole.ADMIN, - ), + admin_user, ) log.debug(f"Project returned: {new_project.__dict__}") assert new_project is not None