Skip to content

Commit

Permalink
test(patients): individual phenopackets endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Sep 12, 2023
1 parent 7639387 commit 43807af
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions chord_metadata_service/patients/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def test_csv_export(self):
self.assertIn(column, [column_name.lower() for column_name in headers])


class IndividualFullTextSearchTest(APITestCase):
class IndividualWithPhenopacketSearchTest(APITestCase):
""" Test for api/individuals?search= """

def setUp(self):
Expand All @@ -165,7 +165,7 @@ def setUp(self):
**ph_c.valid_phenopacket(subject=self.individual_one, meta_data=self.metadata_1)
)

def test_search(self):
def test_search(self): # test full-text search
get_resp_1 = self.client.get('/api/individuals?search=P49Y')
self.assertEqual(get_resp_1.status_code, status.HTTP_200_OK)
response_obj_1 = get_resp_1.json()
Expand All @@ -176,13 +176,19 @@ def test_search(self):
response_obj_2 = get_resp_2.json()
self.assertEqual(len(response_obj_2['results']), 2)

def test_search_bento_search_format(self):
def test_search_bento_search_format(self): # test full-text search - bento search result format
get_resp_1 = self.client.get('/api/individuals?search=P49Y&format=bento_search_result')
self.assertEqual(get_resp_1.status_code, status.HTTP_200_OK)
response_obj_1 = get_resp_1.json()
self.assertEqual(len(response_obj_1['results']), 1)
self.assertEqual(len(response_obj_1['results'][0]), 4) # 4 fields in the bento search response

def test_individual_phenopackets(self):
get_resp_1 = self.client.get(f"/api/individuals/{self.individual_one.id}/phenopackets")
self.assertEqual(get_resp_1.status_code, status.HTTP_200_OK)
response_obj_1 = get_resp_1.json()
self.assertEqual(len(response_obj_1), 1) # 1 phenopacket for individual


# Note: the next five tests use the same setUp method. Initially they were
# all combined in the same class. But this caused bugs with regard to unavailable
Expand Down

0 comments on commit 43807af

Please sign in to comment.