From d2ae7679000b6299c408d34f88a1c5c66755288c Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 27 May 2020 17:07:18 +0100 Subject: need to fix permission denied 403 tests --- ctrack/users/tests/test_views.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'ctrack/users/tests/test_views.py') diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py index ae7fbd7..6cbe9b6 100644 --- a/ctrack/users/tests/test_views.py +++ b/ctrack/users/tests/test_views.py @@ -2,6 +2,7 @@ import pytest from django.test import RequestFactory from ctrack.core.views import home_page +from ctrack.organisations.views import OrganisationListView from ctrack.users.models import User from ctrack.users.views import UserDetailView, UserRedirectView, UserUpdateView @@ -145,15 +146,13 @@ def test_stakeholder_user_is_not_staff(django_user_model, stakeholder): def test_user_received_persmission_denied_when_accessing_disallowed_page( - django_user_model, request_factory, stakeholder + django_user_model, request_factory, stakeholder, ): user = django_user_model.objects.create_user(username="toss", password="knob") user.stakeholder = stakeholder user.save() - assert user.has_perm("ctrack.organisations.view_organisation") is True - user.user_permissions.clear() - assert user.has_perm("ctrack.organisations.view_organisation") is False request = request_factory.get("/organisations") request.user = user - response = home_page(request) + assert request.user.is_staff is False + response = OrganisationListView.as_view()(request) assert response.status_code == 403 -- cgit v1.2.3