summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 2831d01fa..f48048eec 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -2064,10 +2064,17 @@ class OperationTest(TestCase, OperationInitTest):
def setUp(self):
IshtarSiteProfile.objects.get_or_create(slug="default", active=True)
self.username, self.password, self.user = create_superuser()
+
self.alt_username, self.alt_password, self.alt_user = create_user()
- self.alt_user.user_permissions.add(
- Permission.objects.get(codename="view_own_operation")
+
+ collaborator = ProfileType.objects.create(txt_idx="test-operation")
+ gp = Group.objects.create(name="Operation own")
+ gp.permissions.add(Permission.objects.get(codename="view_own_operation"))
+ collaborator.groups.add(gp)
+ UserProfile.objects.create(
+ profile_type=collaborator, person=self.alt_user.ishtaruser.person, current=True
)
+
self.orgas = self.create_orgas(self.user)
self.operations = self.create_operation(self.user, self.orgas[0])
self.operations += self.create_operation(self.alt_user, self.orgas[0])
@@ -2364,6 +2371,15 @@ class OperationTest(TestCase, OperationInitTest):
self.assertEqual(response.status_code, 200)
self.assertIn(b'class="card sheet"', response.content)
+ self.alt_user.ishtaruser.generate_permission()
+ c.login(username=self.alt_username, password=self.alt_password)
+ response = c.get(reverse("show-operation", kwargs={"pk": operation.pk}))
+ # not own operation
+ self.assertEqual(response.status_code, 403)
+ response = c.get(reverse("show-operation", kwargs={"pk": self.operations[-1].pk}))
+ # OK
+ self.assertEqual(response.status_code, 200)
+
def test_show_history(self):
operation = self.operations[-1]
c = Client()
@@ -2380,6 +2396,7 @@ class OperationTest(TestCase, OperationInitTest):
self.assertIn(b'class="card sheet"', response.content)
self.assertIn(b"/show-historized-operation/", response.content)
+ self.alt_user.ishtaruser.generate_permission()
c.login(username=self.alt_username, password=self.alt_password)
response = c.get(reverse("show-operation", kwargs={"pk": operation.pk}))
self.assertEqual(response.status_code, 200)