diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-31 17:27:13 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-31 17:27:13 +0100 |
commit | cc897d624d091c679ef304df9ff35f1093ae1ac0 (patch) | |
tree | cedc3f5b0f494104ea6399a63768e570d735c6e1 /ctrack/conftest.py | |
parent | 656ceb510d535d0592cda7cc92bbe0e43561ea0c (diff) |
created a group fixture with perms
This fixture is a group with all permissions relating to ctrack system
so far.
Diffstat (limited to '')
-rw-r--r-- | ctrack/conftest.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ctrack/conftest.py b/ctrack/conftest.py index 58fabd0..c115b4e 100644 --- a/ctrack/conftest.py +++ b/ctrack/conftest.py @@ -1,6 +1,8 @@ import os import pytest +from django.contrib.auth.models import Group, Permission +from django.db.models import Q from django.test import RequestFactory from selenium import webdriver from selenium.webdriver.firefox.options import Options @@ -29,6 +31,41 @@ def media_storage(settings, tmpdir): @pytest.fixture +def cct_user_group() -> Group: + """ + TODO: An inspector will not require this many permissions! Reduce. + """ + group = Group.objects.create(name="cct_user") + ctrack_permissions = Permission.objects.filter( + Q(codename__contains="address") + | Q(codename__contains="addresstype") + | Q(codename__contains="mode") + | Q(codename__contains="organisation") + | Q(codename__contains="role") + | Q(codename__contains="submode") + | Q(codename__contains="person") + | Q(codename__contains="applicablesystem") + | Q(codename__contains="caf") + | Q(codename__contains="documentfile") + | Q(codename__contains="filestore") + | Q(codename__contains="grading") + | Q(codename__contains="engagementtype") + | Q(codename__contains="engagementevent") + | Q(codename__contains="cafassessment") + | Q(codename__contains="cafobjective") + | Q(codename__contains="cafprinciple") + | Q(codename__contains="cafcontributingoutcome") + | Q(codename__contains="cafassessmentoutcomescore") + | Q(codename__contains="achievmentlevel") + | Q(codename__contains="igp") + | Q(codename__contains="stakeholder") + | Q(codename__contains="incidentreport") + ) + group.permissions.add(*ctrack_permissions) + return group + + +@pytest.fixture def user() -> User: return UserFactory() |