-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added tests for log update API
- Loading branch information
Showing
2 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,43 @@ | ||
import datetime | ||
|
||
from rest_framework import status | ||
|
||
from care.facility.models import PatientRegistration | ||
from care.utils.tests.test_base import TestBase | ||
|
||
|
||
class TestDailyRoundApi(TestBase): | ||
class TestDailyRound(TestBase): | ||
def setUp(self) -> None: | ||
super().setUp() | ||
self.consultation = self.create_consultation() | ||
|
||
def get_url(self, external_consultation_id=None): | ||
return f"/api/v1/consultation/{external_consultation_id}/daily_rounds/analyse/" | ||
|
||
def test_external_consultation_does_not_exists_returns_404(self): | ||
sample_uuid = "e4a3d84a-d678-4992-9287-114f029046d8" | ||
response = self.client.get(self.get_url(sample_uuid)) | ||
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) | ||
|
||
def test_action_in_log_update( | ||
self, | ||
): | ||
log_update = { | ||
"clone_last": False, | ||
"rounds_type": "NORMAL", | ||
"patient_category": "Comfort", | ||
"action": "DISCHARGE_RECOMMENDED", | ||
"taken_at": datetime.datetime.now().isoformat(), | ||
} | ||
response = self.client.post( | ||
f"/api/v1/consultation/{self.consultation.external_id}/daily_rounds/", | ||
data=log_update, | ||
format="json", | ||
) | ||
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | ||
self.assertEqual(response.data["patient_category"], "Comfort Care") | ||
self.assertEqual(response.data["rounds_type"], "NORMAL") | ||
patient = PatientRegistration.objects.get(id=self.consultation.patient_id) | ||
self.assertEqual( | ||
patient.action, PatientRegistration.ActionEnum.DISCHARGE_RECOMMENDED.value | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters