diff options
Diffstat (limited to 'archaeological_warehouse/tests.py')
-rw-r--r-- | archaeological_warehouse/tests.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/archaeological_warehouse/tests.py b/archaeological_warehouse/tests.py index 96df83024..e92298c9f 100644 --- a/archaeological_warehouse/tests.py +++ b/archaeological_warehouse/tests.py @@ -20,7 +20,7 @@ import datetime import json -from django.contrib.auth.models import Permission, User +from django.contrib.auth.models import Permission, Group from django.db.utils import IntegrityError from django.test.client import Client from django.urls import reverse @@ -38,10 +38,11 @@ from ishtar_common.tests import ( create_superuser, ) -from ishtar_common.models import IshtarSiteProfile +from ishtar_common.models import IshtarSiteProfile, ProfileType, UserProfile from archaeological_operations.models import Operation from archaeological_context_records.models import ContextRecord -from archaeological_finds.models import Find, MaterialType, Treatment, TreatmentType, FindTreatment, TreatmentState +from archaeological_finds.models import \ + Find, MaterialType, Treatment, TreatmentType, FindTreatment, TreatmentState from archaeological_warehouse import models, views, forms, serializers @@ -808,7 +809,22 @@ class ContainerTest(FindInit, TestCase): container_2.index = 42000 container_2.save() username, password, user = create_user() - user.user_permissions.add(Permission.objects.get(codename="view_warehouse")) + + profile_type = ProfileType.objects.create( + label="xxCollaborateur", + txt_idx="xxcollaborator", + ) + gp = Group.objects.create(name="xxLieu de conservation : voir") + gp.permissions.add(Permission.objects.get(codename="view_warehouse")) + gp.permissions.add(Permission.objects.get(codename="view_own_container")) + profile_type.groups.add(gp) + UserProfile.objects.create( + profile_type=profile_type, + person=user.ishtaruser.person, + current=True, + ) + user.ishtaruser.generate_permission() + client = Client() client.login(username=username, password=password) url = "/autocomplete-container/{}/".format(self.main_warehouse.pk) |