diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-28 13:28:19 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-28 13:28:19 +0100 |
commit | df8f55519b2e2ed0db5e3175041c8d4321c830b8 (patch) | |
tree | 06ce0e8e64b0794ccf8e5350f1c3685196bffed4 /ctrack/users/tests/test_views.py | |
parent | 38d0771eed7185fad90977a264a5dcc16aa2bb07 (diff) |
user with permission can view OrganisationListView
Diffstat (limited to 'ctrack/users/tests/test_views.py')
-rw-r--r-- | ctrack/users/tests/test_views.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ctrack/users/tests/test_views.py b/ctrack/users/tests/test_views.py index fdd5633..8dc4825 100644 --- a/ctrack/users/tests/test_views.py +++ b/ctrack/users/tests/test_views.py @@ -146,7 +146,7 @@ def test_stakeholder_user_is_not_staff(django_user_model, stakeholder): assert user.is_staff is False -def test_regular_user_gets_301_when_trying_to_access_view_with_perm_set( +def test_stakeholder_user_gets_301_when_trying_to_access_view_with_perm_set( django_user_model, client, stakeholder ): """ @@ -163,3 +163,20 @@ def test_regular_user_gets_301_when_trying_to_access_view_with_perm_set( assert ( response.status_code == 301 ) # This page redirects to 403.html, hence why its a 301 (I think) + + +@pytest.mark.skip("Explore why this does not pass - it passess in functional style") +def test_staff_user_gets_200_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 + org_list_permission = Permission.objects.get(name="Can view organisation") + assert user.user_permissions.count() == 0 + user.user_permissions.add(org_list_permission) + assert user.has_perm("organisations.view_organisation") + user.save() + logged_in = client.login(username="toss", password="knob") + assert logged_in is True + response = client.get("/organisations") + assert response.status_code == 200 |