Skip to content

Commit

Permalink
test: update auth user creation for fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jul 2, 2024
1 parent 0a1e4c5 commit 553614b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 553614b

Please sign in to comment.