diff options
Diffstat (limited to 'ctrack/users/tests/test_views.py')
-rw-r--r-- | ctrack/users/tests/test_views.py | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py index ebc38d8..cf6b05a 100644 --- a/ctrack/users/tests/test_views.py +++ b/ctrack/users/tests/test_views.py @@ -146,23 +146,20 @@ def test_stakeholder_user_is_not_staff(django_user_model, stakeholder): assert user.is_staff is False -def test_user_received_persmission_denied_when_accessing_disallowed_page( - django_user_model, request_factory, stakeholder, +def test_regular_user_gets_301_when_trying_to_access_view_with_perm_set( + django_user_model, client, stakeholder ): - user = django_user_model.objects.create_user(username="toss", password="knob") - user.stakeholder = stakeholder - user.save() - request = request_factory.get("/organisations") - request.user = user - assert request.user.is_staff is False - response = OrganisationListView.as_view()(request) - assert response.status_code == 403 - - -def test_user_gets_403(django_user_model, client, stakeholder): + """ + No permissions are set when a regular user is created. This test knows that a suitable + permission is set on the ctrack.organisations.view.OrganisationListView, and therefore we + would expect a redirect/403 persmission denied response when trying to reach it with a + regular user. + """ user = django_user_model.objects.create_user(username="toss", password="knob") user.stakeholder = stakeholder user.save() client.login(username="toss", password="knob") response = client.get(path="https://localhost:8000/organisations") - assert response.status_code == 403 + assert ( + response.status_code == 301 + ) # at this point, I don't know why it's a 301 not a 403 |