Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tortila committed Jul 12, 2023
1 parent 5302123 commit 86af8a6
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions apps/accounts/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,15 +527,26 @@ def test_user_admin_displays_managed_providers_and_dcs(
assert datacenter.name in user_admin.managed_datacenters(sample_hoster_user)

def test_user_cannot_access_another_user_change_view(
self, db, sample_hoster_user, greenweb_staff_user
self, db, client, sample_hoster_user, greenweb_staff_user
):
user_admin = ac_admin.CustomUserAdmin(ac_models.User, admin_site.greenweb_admin)
request = MagicMock()
request.user = sample_hoster_user
response = user_admin.change_view(request, str(greenweb_staff_user.id))
client.force_login(sample_hoster_user)
change_user_url = urls.reverse(
"greenweb_admin:accounts_user_change", args=[greenweb_staff_user.id]
)
response = client.get(change_user_url)
assert response.status_code == 302
assert response.url == "/admin/"

def test_staff_can_access_another_user_change_view(
self, db, client, sample_hoster_user, greenweb_staff_user
):
client.force_login(greenweb_staff_user)
change_user_url = urls.reverse(
"greenweb_admin:accounts_user_change", args=[sample_hoster_user.id]
)
response = client.get(change_user_url)
assert response.status_code == 200


def test_provider_request_accessible_by_admin(
db,
Expand Down

0 comments on commit 86af8a6

Please sign in to comment.