diff options
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index bfd2a162b..18d927d06 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -3767,6 +3767,20 @@ class OperationPermissionTest(TestCase, TestPermissionRequest, OperationInitTest ) # nosec: hard coded password for test purposes + asso_date_username, asso_date_password, asso_date_user = create_user( # nosec + username="darth", password="maul" + ) + self.profile_date = UserProfile.objects.create( + profile_type=self.profile_types["ope_associated_items"], + person=asso_date_user.ishtaruser.person, + expiration_date=datetime.date.today(), + current=True, + ) + self.users["asso_date"] = ( + asso_date_username, asso_date_password, asso_date_user + ) + + # nosec: hard coded password for test purposes areas_username, areas_password, areas_user = create_user( # nosec username="luke", password="iamyourfather" ) @@ -3882,6 +3896,21 @@ class OperationPermissionTest(TestCase, TestPermissionRequest, OperationInitTest ) self.assertEqual(json.loads(response.content.decode())["recordsTotal"], 1) + asso_date_username, asso_date_password, asso_date_user = self.users["asso_date"] + self.operations[1].ishtar_users.add(asso_date_user.ishtaruser) + asso_date_user.ishtaruser.generate_permission() + c = Client() + c.login(username=asso_date_username, password=asso_date_password) + response = c.get(reverse("get-operation"), {"year": "2010"}) + self.assertTrue(json.loads(response.content.decode())) + self.assertEqual(json.loads(response.content.decode())["recordsTotal"], 1) + + self.profile_date.expiration_date = datetime.date.today() - datetime.timedelta(days=1) + self.profile_date.save() + asso_date_user.ishtaruser.generate_permission() + response = c.get(reverse("get-operation"), {"year": "2010"}) + self.assertFalse(json.loads(response.content.decode())) + def test_own_modify(self): operation_pk1 = self.operations[0].pk operation_pk2 = self.operations[1].pk |