aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/users/tests/test_functional.py
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-05-28 13:28:19 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-05-28 13:28:19 +0100
commitdf8f55519b2e2ed0db5e3175041c8d4321c830b8 (patch)
tree06ce0e8e64b0794ccf8e5350f1c3685196bffed4 /ctrack/users/tests/test_functional.py
parent38d0771eed7185fad90977a264a5dcc16aa2bb07 (diff)
user with permission can view OrganisationListView
Diffstat (limited to 'ctrack/users/tests/test_functional.py')
-rw-r--r--ctrack/users/tests/test_functional.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/ctrack/users/tests/test_functional.py b/ctrack/users/tests/test_functional.py
index 4e1f532..da9d088 100644
--- a/ctrack/users/tests/test_functional.py
+++ b/ctrack/users/tests/test_functional.py
@@ -9,6 +9,7 @@ a regular user or a stakeholder user.
import time
import pytest
+from django.contrib.auth.models import Permission
from ctrack.users.models import User
@@ -80,3 +81,26 @@ def test_stakeholder_can_log_in_but_receieved_permisson_denied_when_off_piste(
assert "Sorry. You do not have permission to view this page." in [
x.text for x in browser.find_elements_by_tag_name("p")
]
+
+
+def test_stakeholder_user_with_permissions_can_view_page(
+ browser, live_server, stakeholder
+):
+ user = User.objects.create_user(username="toss", password="knob")
+ user.stakeholder = stakeholder
+ org_list_permission = Permission.objects.get(name="Can view organisation")
+
+ # Add the permission to view an Organisation, which is set on OrganisationListView
+ assert user.user_permissions.count() == 0
+ user.user_permissions.add(org_list_permission)
+ assert user.user_permissions.count() == 1
+ user.save()
+
+ browser.get(live_server + "/accounts/login")
+ browser.find_element_by_id("id_login").send_keys("toss")
+ browser.find_element_by_id("id_password").send_keys("knob")
+ browser.find_element_by_id("sign_in_button").submit()
+ time.sleep(1)
+ # Try to browser to Organisations list
+ browser.get(live_server + "/organisations")
+ assert "Organisations" in browser.title