Skip to content

Commit

Permalink
gps: Add test on admin
Browse files Browse the repository at this point in the history
  • Loading branch information
tonial committed Jan 17, 2025
1 parent 8755df6 commit 3e2a3a2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/gps/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from django.contrib.auth import get_user
from django.urls import reverse
from pytest_django.asserts import assertContains

Expand Down Expand Up @@ -42,3 +43,28 @@ def test_participant_admin_link(admin_client, user_factory):

# Assert that the lookup works
admin_client.get(expected_url)


def test_create_follow_up_membership(admin_client):
group = FollowUpGroupFactory()
prescriber = PrescriberFactory()

url = reverse("admin:gps_followupgroupmembership_add")

post_data = {
"is_active": "on",
"follow_up_group": group.pk,
"member": prescriber.pk,
}
response = admin_client.post(url, data=post_data)
assert response.status_code == 302

membership = group.memberships.get()
assert membership.creator == get_user(admin_client)
assert membership.ended_at is None

url = reverse("admin:gps_followupgroupmembership_change", args=(membership.pk,))
response = admin_client.post(url, data={}) # no is_active to set it to False

membership.refresh_from_db()
assert membership.ended_at is not None

0 comments on commit 3e2a3a2

Please sign in to comment.