Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekGawd committed Jul 28, 2023
1 parent 87ce33d commit 0cac0c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
17 changes: 9 additions & 8 deletions care/facility/tests/test_asset_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.db import transaction
from rest_framework import status
from rest_framework.test import APIRequestFactory, APITestCase
from rest_framework.test import APIRequestFactory
from rest_framework_simplejwt.tokens import RefreshToken

from care.facility.api.viewsets.asset import AssetViewSet
Expand Down Expand Up @@ -59,7 +59,7 @@ class ExpectedAssetRetrieveKeys(Enum):
NOTES = "notes"


class AssetViewSetTestCase(TestBase, TestClassMixin, APITestCase):
class AssetViewSetTestCase(TestBase, TestClassMixin):
endpoint = "/api/v1/asset/"
asset_id = None

Expand All @@ -71,19 +71,20 @@ def setUpClass(cls):
district = cls.create_district(state=state)
cls.user = cls.create_user(district=district, username="test user")
facility = cls.create_facility(district=district, user=cls.user)
# Refresh token to header
refresh_token = RefreshToken.for_user(cls.user)
cls.client.credentials(
HTTP_AUTHORIZATION=f"Bearer {refresh_token.access_token}"
)

cls.asset1_location = AssetLocation.objects.create(
name="asset1 location", location_type=1, facility=facility
)
cls.asset = Asset.objects.create(
name="Test Asset", current_location=cls.asset1_location, asset_type=50
)

def setUp(self):
# Refresh token to header
refresh_token = RefreshToken.for_user(self.user)
self.client.credentials(
HTTP_AUTHORIZATION=f"Bearer {refresh_token.access_token}"
)

def test_list_assets(self):
response = self.client.get(self.endpoint)

Expand Down
7 changes: 4 additions & 3 deletions care/utils/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,13 @@ def create_consultation(
data.update(kwargs)
return PatientConsultation.objects.create(**data)

@classmethod
def create_patient_note(
self, patient=None, facility=None, note="Patient is doing find", **kwargs
cls, patient=None, facility=None, note="Patient is doing find", **kwargs
):
data = {
"patient": patient or self.patient,
"facility": facility or self.facility,
"patient": patient or cls.patient,
"facility": facility or cls.facility,
"note": note,
}
data.update(kwargs)
Expand Down

0 comments on commit 0cac0c6

Please sign in to comment.