-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 the fixture | ||
with_environment_permissions. | ||
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 | ||
|
||
|
||
|
@@ -156,6 +176,29 @@ def environment(project): | |
return Environment.objects.create(name="Test Environment", project=project) | ||
|
||
|
||
@pytest.fixture() | ||
def with_environment_permissions( | ||
environment: Environment, staff_user: FFAdminUser | ||
) -> typing.Callable: | ||
""" | ||
Add environment permissions to the staff_user fixture. | ||
Defaults to associating to the environment fixture. | ||
""" | ||
|
||
def _with_environment_permissions( | ||
permission_keys: list[str], environment_id: typing.Optional[int] = None | ||
) -> UserEnvironmentPermission: | ||
environment_id = environment_id or environment.id | ||
uep, __ = UserEnvironmentPermission.objects.get_or_create( | ||
environment_id=environment_id, user=staff_user | ||
) | ||
uep.permissions.add(*permission_keys) | ||
|
||
return uep | ||
|
||
return _with_environment_permissions | ||
|
||
|
||
@pytest.fixture() | ||
def identity(environment): | ||
return Identity.objects.create(identifier="test_identity", environment=environment) | ||
|
a09436d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com
docs-git-main-flagsmith.vercel.app
a09436d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-preview-flagsmith.vercel.app
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
flagsmith-frontend-production-native.vercel.app
a09436d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
flagsmith-staging-frontend.vercel.app
flagsmith-frontend-staging-flagsmith.vercel.app
staging.flagsmith.com