Skip to content

Commit

Permalink
add tets
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkurPrabhu committed May 19, 2024
1 parent 39f4321 commit 6075beb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions care/facility/tests/test_bed_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from rest_framework.test import APITestCase

from care.facility.models import Bed
from care.facility.models.bed import AssetBed
from care.utils.assetintegration.asset_classes import AssetClasses
from care.utils.tests.test_utils import TestUtils


Expand Down Expand Up @@ -36,3 +38,28 @@ def test_list_beds(self):
with self.assertNumQueries(5):
response = self.client.get("/api/v1/bed/")
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_list_non_occupied_beds(self):
linked_bed = Bed.objects.create(
name="linked_bed",
location=self.asset_location,
facility=self.facility,
)
asset = self.create_asset(
self.asset_location, asset_class=AssetClasses.HL7MONITOR.name
)
AssetBed.objects.create(bed=linked_bed, asset=asset)

# 4 beds 1 linked with HL7MONITOR and 3 created in setup

response = self.client.get("/api/v1/bed/")

# Assert list returns 4 beds
self.assertEqual(response.json()["count"], 4)

response_with_not_occupied_bed = self.client.get(
"/api/v1/bed/?not_occupied_by_asset_type=HL7MONITOR"
)

# Assert count of unoccupied beds is 3
self.assertEqual(response_with_not_occupied_bed.json()["count"], 3)

0 comments on commit 6075beb

Please sign in to comment.