Skip to content

Commit

Permalink
Merge pull request #4729 from opensafely-core/iaindillingham/parametr…
Browse files Browse the repository at this point in the history
…ize-test

Parametrize test
  • Loading branch information
iaindillingham authored Nov 8, 2024
2 parents 04f199e + 142d4a6 commit afb4bdb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/unit/staff/views/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,18 @@ def test_userlist_filter_by_invalid_org(rf, staff_area_administrator):
assert len(response.context_data["object_list"]) == 0


def test_userlist_filter_by_role(rf, staff_area_administrator):
UserFactory(roles=[OutputPublisher])
UserFactory(roles=[ProjectCollaborator])

request = rf.get("/?role=OutputPublisher")
@pytest.mark.parametrize(
"role",
[
pytest.param(OutputPublisher, id="global"),
pytest.param(ProjectDeveloper, id="local"),
],
)
def test_userlist_filter_by_role(rf, staff_area_administrator, role):
# Set up two users: one as the staff area administrator to request the view and
# be filtered out, the other to be included in the response after filtering.
UserFactory(roles=[role])
request = rf.get(f"/?role={role.__name__}")
request.user = staff_area_administrator

response = UserList.as_view()(request)
Expand Down

0 comments on commit afb4bdb

Please sign in to comment.