Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rend visible le snapshot d'acceptation de visa aux pros #1422

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading