aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/organisations
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-05-31 12:39:39 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-05-31 12:39:39 +0100
commit65a2075bdbcf731507c25e0eb8737a1bbf3ac2bd (patch)
tree0a77c3ff9d375bcad9b3ff8e6689e773cfb067f0 /ctrack/organisations
parentaf2b9c55ef2b9e821119124be727f4beb0e2b7b9 (diff)
another testing passing related to groups
Diffstat (limited to '')
-rw-r--r--ctrack/organisations/tests/test_views.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/ctrack/organisations/tests/test_views.py b/ctrack/organisations/tests/test_views.py
index 8e8fff7..7f9da0a 100644
--- a/ctrack/organisations/tests/test_views.py
+++ b/ctrack/organisations/tests/test_views.py
@@ -1,6 +1,6 @@
import pytest
from django.contrib.auth import get_user_model
-from django.contrib.auth.models import Permission
+from django.contrib.auth.models import Group, Permission
from django.test import RequestFactory
from ctrack.organisations.tests.factories import OrganisationFactory
@@ -35,6 +35,25 @@ def test_organisation_list_view():
assert len(response.context_data["organisation_list"]) == 3
+def test_only_member_of_cct_user_group_can_view_org_list():
+
+ OrganisationFactory.create()
+ OrganisationFactory.create()
+ OrganisationFactory.create()
+
+ group = Group.objects.create(name="cct_user")
+
+ factory = RequestFactory()
+ user = get_user_model().objects.create_user(
+ username="testy", email="testy@test.com", password="test1020"
+ )
+ user.groups.add(group)
+ org_list_permission = Permission.objects.get(name="Can view organisation")
+ group.permissions.add(org_list_permission)
+ # They get this permisson via the cct_user group
+ assert user.has_perm("organisations.view_organisation")
+
+
def test_incident_report_create_view(stakeholder_user):
org = OrganisationFactory.create()
factory = RequestFactory()