From e0fb4edbad3512d561fc4179b5d0b28656313296 Mon Sep 17 00:00:00 2001 From: Alejandro MG Date: Fri, 27 Dec 2024 14:44:44 +0100 Subject: [PATCH] Ensures visa acceptance snapshots are visible to pros --- api/tests/test_snapshot.py | 28 ++++++++++++++++++++++++++++ api/views/snapshot.py | 1 - 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/api/tests/test_snapshot.py b/api/tests/test_snapshot.py index 439fa2d7..808f2118 100644 --- a/api/tests/test_snapshot.py +++ b/api/tests/test_snapshot.py @@ -355,6 +355,34 @@ def test_snapshot_hide_visa_to_declarants(self): self.assertEqual(body[0]["id"], snapshot.id) self.assertEqual(body[0]["comment"], snapshot.comment) + @authenticate + def test_snapshot_show_visa_approval_to_declarants(self): + declarant_role = DeclarantRoleFactory(user=authenticate.user) + company = declarant_role.company + + # Une déclaration avec toutes les conditions nécessaires pour l'instruction + declaration = InstructionReadyDeclarationFactory(author=authenticate.user, company=company) + snapshot = SnapshotFactory( + declaration=declaration, user=authenticate.user, action=Snapshot.SnapshotActions.SUBMIT + ) + SnapshotFactory(declaration=declaration, user=authenticate.user, action=Snapshot.SnapshotActions.REQUEST_VISA) + visa_accept_snapshot = SnapshotFactory( + declaration=declaration, user=authenticate.user, action=Snapshot.SnapshotActions.ACCEPT_VISA + ) + + # On obtient les snapshots liés à cette déclaration. Cet user n'est pas viseur ni instructeur, + # mais la validation du visa doit être communiqué + + response = self.client.get(reverse("api:declaration_snapshots", kwargs={"pk": declaration.id})) + self.assertEqual(response.status_code, status.HTTP_200_OK) + body = response.json() + self.assertEqual(len(body), 2) + self.assertEqual(body[0]["id"], snapshot.id) + self.assertEqual(body[0]["comment"], snapshot.comment) + + self.assertEqual(body[1]["id"], visa_accept_snapshot.id) + self.assertEqual(body[1]["comment"], visa_accept_snapshot.comment) + @authenticate def test_snapshot_hide_visa_to_supervisors(self): supervision_role = SupervisorRoleFactory(user=authenticate.user) diff --git a/api/views/snapshot.py b/api/views/snapshot.py index 1e9048b5..88c7287f 100644 --- a/api/views/snapshot.py +++ b/api/views/snapshot.py @@ -22,7 +22,6 @@ def get_queryset(self): action__in=[ Snapshot.SnapshotActions.REQUEST_VISA, Snapshot.SnapshotActions.TAKE_FOR_VISA, - Snapshot.SnapshotActions.ACCEPT_VISA, Snapshot.SnapshotActions.REFUSE_VISA, ] )