Skip to content

Commit

Permalink
add test for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan committed Nov 28, 2024
1 parent b0067fd commit 41563b6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions care/facility/tests/test_facilityuser_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def setUpTestData(cls) -> None:
cls.facility2 = cls.create_facility(
cls.super_user, cls.district, cls.local_body
)
cls.user2 = cls.create_user(
"dummystaff", cls.district, home_facility=cls.facility2
)

def setUp(self) -> None:
self.client.force_authenticate(self.super_user)
Expand All @@ -32,6 +35,15 @@ def test_get_queryset_with_prefetching(self):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertNumQueries(2)

def test_get_queryset_with_search(self):
response = self.client.get(
f"/api/v1/facility/{self.facility2.external_id}/get_users/?username={self.user2.username}"
)

self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.data["results"]), 1)
self.assertEqual(response.data["results"][0]["username"], self.user2.username)

def test_link_new_facility(self):
response = self.client.get("/api/v1/facility/")

Expand Down

0 comments on commit 41563b6

Please sign in to comment.