Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create staff fixture #2928

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,29 @@ def test_user_client(api_client, test_user):


@pytest.fixture()
def organisation(db, admin_user):
def staff_user(django_user_model):
"""
A non-admin user fixture.
To add to an environment with permissions use:
uep = UserEnvironmentPermission.objects.create ...
uep.permissions.add ...
This fixture is attached to the organisation fixture.
"""
return django_user_model.objects.create(email="[email protected]")


@pytest.fixture()
def staff_client(staff_user):
client = APIClient()
client.force_authenticate(user=staff_user)
return client


@pytest.fixture()
def organisation(db, admin_user, staff_user):
org = Organisation.objects.create(name="Test Org")
admin_user.add_organisation(org, role=OrganisationRole.ADMIN)
staff_user.add_organisation(org, role=OrganisationRole.USER)
return org


Expand Down