Skip to content

Commit

Permalink
gps: Display membership date
Browse files Browse the repository at this point in the history
Now that we have the correct date
  • Loading branch information
tonial committed Jul 11, 2024
1 parent d6abca6 commit e44457d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
12 changes: 5 additions & 7 deletions tests/gps/__snapshots__/test_views.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,11 @@
<div>

<div>

<div>


Vous avez ajouté ce bénéficiaire le <strong>21/06/2024</strong>.
</div>

<div>


Vous avez ajouté ce bénéficiaire le <strong>21/06/2024</strong>.
</div>

1 autre professionnel
est
Expand Down
28 changes: 2 additions & 26 deletions tests/gps/test_views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import datetime

import freezegun
import pytest
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
from pytest_django.asserts import assertContains, assertRedirects
Expand Down Expand Up @@ -195,28 +193,6 @@ def test_my_groups(snapshot, client):
user = PrescriberFactory(membership__organization__authorized=True, membership__organization__for_snapshot=True)
client.force_login(user)

# Was created in bulk.
group = FollowUpGroupFactory(
memberships=1,
beneficiary__first_name="Paco",
beneficiary__last_name="de Lucia",
created_in_bulk=True,
)

FollowUpGroup.objects.follow_beneficiary(beneficiary=group.beneficiary, user=user, is_referent=True)
membership = group.memberships.get(member=user)
membership.created_at = datetime.datetime.combine(
settings.GPS_GROUPS_CREATED_AT_DATE, datetime.time(), tzinfo=datetime.UTC
)
membership.created_in_bulk = True
membership.save()

response = client.get(reverse("gps:my_groups"))
assert response.status_code == 200
groups = parse_response_to_soup(response, selector="#follow-up-groups-section").select(".membership-card")
assert len(groups) == 1
assert "Vous avez ajouté ce bénéficiaire le" not in str(groups[0])

# Nominal case
# Groups created latelly should come first.
group = FollowUpGroupFactory(memberships=1, for_snapshot=True)
Expand All @@ -230,15 +206,15 @@ def test_my_groups(snapshot, client):
("data-bs-confirm-url", f"/gps/groups/{group.pk}", "/gps/groups/[PK of Group]"),
],
).select(".membership-card")
assert len(groups) == 2
assert len(groups) == 1
assert str(groups[0]) == snapshot(name="test_my_groups__group_card")

# Test `is_referent` display.
group = FollowUpGroupFactory(memberships=1, beneficiary__first_name="Janis", beneficiary__last_name="Joplin")
FollowUpGroup.objects.follow_beneficiary(beneficiary=group.beneficiary, user=user, is_referent=True)
response = client.get(reverse("gps:my_groups"))
groups = parse_response_to_soup(response, selector="#follow-up-groups-section").select(".membership-card")
assert len(groups) == 3
assert len(groups) == 2
assert "Janis" in str(groups[0])
assert "et êtes <strong>référent</strong>" in str(groups[0])

Expand Down

0 comments on commit e44457d

Please sign in to comment.