From f7d8c81536f923cef17e1abd0f96dbb8973d8ab6 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 17 Jan 2024 17:22:46 +0530 Subject: [PATCH] Refactor PatientFilterTestCase to use base URL --- care/facility/tests/test_patient_api.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/care/facility/tests/test_patient_api.py b/care/facility/tests/test_patient_api.py index 0167300fb4..f4512c1ed3 100644 --- a/care/facility/tests/test_patient_api.py +++ b/care/facility/tests/test_patient_api.py @@ -245,9 +245,12 @@ def setUpTestData(cls): cls.patient.last_consultation = cls.consultation cls.patient.save() + def get_base_url(self) -> str: + return "/api/v1/patient/" + def test_filter_by_patient_no(self): self.client.force_authenticate(user=self.user) - response = self.client.get("/api/v1/patient/?patient_no=IP5678") + response = self.client.get(self.get_base_url(), {"patient_no": "IP5678"}) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data["count"], 1) self.assertEqual( @@ -257,7 +260,11 @@ def test_filter_by_patient_no(self): def test_filter_by_location(self): self.client.force_authenticate(user=self.user) response = self.client.get( - f"/api/v1/patient/?facility={self.facility.external_id}&location={self.location.external_id}" + self.get_base_url(), + { + "facility": self.facility.external_id, + "location": self.location.external_id, + }, ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data["count"], 1)