Skip to content

Commit

Permalink
test: create test user account as ADMIN permission
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Feb 6, 2024
1 parent 4cc90b0 commit e5757a2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from app.db.database import Base, get_db
from app.db.db_models import DbOrganisation, DbUser
from app.main import get_application
from app.models.enums import UserRole
from app.projects import project_crud
from app.projects.project_schemas import ODKCentralDecrypted, ProjectInfo, ProjectUpload

Expand Down Expand Up @@ -85,9 +86,9 @@ def db(db_engine):


@pytest.fixture(scope="function")
def user(db):
def admin_user(db):
"""A test user."""
db_user = DbUser(id=100, username="test_user")
db_user = DbUser(id=100, username="test_user", role=UserRole.ADMIN)
db.add(db_user)
db.commit()
return db_user
Expand All @@ -110,7 +111,7 @@ def organisation(db):


@pytest.fixture(scope="function")
async def project(db, user, organisation):
async def project(db, admin_user, organisation):
"""A test project, using the test user and org."""
project_metadata = ProjectUpload(
project_info=ProjectInfo(
Expand Down Expand Up @@ -150,7 +151,11 @@ async def project(db, user, organisation):
db,
project_metadata,
odkproject["id"],
AuthUser(username=user.username, id=user.id),
AuthUser(
username=admin_user.username,
id=admin_user.id,
role=UserRole.ADMIN,
),
)
log.debug(f"Project returned: {new_project.__dict__}")
assert new_project is not None
Expand Down

0 comments on commit e5757a2

Please sign in to comment.