Skip to content

Commit

Permalink
Merge pull request #1422 from betagouv/1421-invisible-snapshots
Browse files Browse the repository at this point in the history
Rend visible le snapshot d'acceptation de visa aux pros
  • Loading branch information
alemangui authored Dec 27, 2024
2 parents 211c36a + e0fb4ed commit f948904
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
28 changes: 28 additions & 0 deletions api/tests/test_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion api/views/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
)
Expand Down

0 comments on commit f948904

Please sign in to comment.