1919 assert_fhir_response ,
2020 assert_has_results ,
2121 extract_resource_ids ,
22+ extract_resource_fields
2223)
2324
2425
@@ -221,53 +222,53 @@ def test_list_default(self):
221222 self .assertIn ("participatingOrganization" , org_affiliation_entry )
222223 self .assertIn ("endpoint" , org_affiliation_entry )
223224
224- # def test_list_in_default_order(self):
225- # url = reverse("fhir-organizationaffiliation-list")
226- # response = self.client.get(url)
227- # assert_fhir_response(self, response)
228- #
229- # particpiationg_orgs = extract_resource_fields(response, "participatingOrganization")
230- # participating_org_names = [org["display"] for org in particpiationg_orgs]
231- #
232- # sorted = ["A Good Clinical Org", "B Good Clinical Org", "C Good Clinical Org"]
233- #
234- # self.assertEqual(
235- # participating_org_names,
236- # sorted,
237- # f"Expected fhir org affilations sorted by participating org name but got {participating_org_names}\n Sorted: {sorted}",
238- # )
239- #
240- # def test_list_in_descending_order(self):
241- # url = reverse("fhir-organizationaffiliation-list")
242- # response = self.client.get(url, {"_sort": "-organization_name"})
243- # assert_fhir_response(self, response)
244- #
245- # particpiationg_orgs = extract_resource_fields(response, "participatingOrganization")
246- # participating_org_names = [org["display"] for org in particpiationg_orgs]
247- #
248- # sorted = ["C Good Clinical Org", "B Good Clinical Org", "A Good Clinical Org"]
249- #
250- # self.assertEqual(
251- # participating_org_names,
252- # sorted,
253- # f"Expected fhir org affilations sorted in descending order by participating org name but got {participating_org_names}\n Sorted: {sorted}",
254- # )
255- #
256- # def test_list_in_ehr_vendor_order(self):
257- # url = reverse("fhir-organizationaffiliation-list")
258- # response = self.client.get(url, {"_sort": "ehr_vendor_name"})
259- # assert_fhir_response(self, response)
260- #
261- # ehr_orgs = extract_resource_fields(response, "organization")
262- # ehr_org_names = [org["display"] for org in ehr_orgs]
263- #
264- # sorted = ["Epic", "Legendary", "Zod"]
265- #
266- # self.assertEqual(
267- # ehr_org_names,
268- # sorted,
269- # f"Expected fhir org affilations sorted in descending order by ehr org name but got {ehr_org_names}\n Sorted: {sorted}",
270- # )
225+ def test_list_in_default_order (self ):
226+ url = reverse ("fhir-organizationaffiliation-list" )
227+ response = self .client .get (url )
228+ assert_fhir_response (self , response )
229+
230+ particpiationg_orgs = extract_resource_fields (response , "participatingOrganization" )
231+ participating_org_names = [org ["display" ] for org in particpiationg_orgs ]
232+
233+ sorted = ["A Good Clinical Org" , "B Good Clinical Org" , "C Good Clinical Org" ]
234+
235+ self .assertEqual (
236+ participating_org_names ,
237+ sorted ,
238+ f"Expected fhir org affilations sorted by participating org name but got { participating_org_names } \n Sorted: { sorted } " ,
239+ )
240+
241+ def test_list_in_descending_order (self ):
242+ url = reverse ("fhir-organizationaffiliation-list" )
243+ response = self .client .get (url , {"_sort" : "-organization_name" })
244+ assert_fhir_response (self , response )
245+
246+ particpiationg_orgs = extract_resource_fields (response , "participatingOrganization" )
247+ participating_org_names = [org ["display" ] for org in particpiationg_orgs ]
248+
249+ sorted = ["C Good Clinical Org" , "B Good Clinical Org" , "A Good Clinical Org" ]
250+
251+ self .assertEqual (
252+ participating_org_names ,
253+ sorted ,
254+ f"Expected fhir org affilations sorted in descending order by participating org name but got { participating_org_names } \n Sorted: { sorted } " ,
255+ )
256+
257+ def test_list_in_ehr_vendor_order (self ):
258+ url = reverse ("fhir-organizationaffiliation-list" )
259+ response = self .client .get (url , {"_sort" : "ehr_vendor_name" })
260+ assert_fhir_response (self , response )
261+
262+ ehr_orgs = extract_resource_fields (response , "organization" )
263+ ehr_org_names = [org ["display" ] for org in ehr_orgs ]
264+
265+ sorted = ["Epic" , "Legendary" , "Zod" ]
266+
267+ self .assertEqual (
268+ ehr_org_names ,
269+ sorted ,
270+ f"Expected fhir org affilations sorted in descending order by ehr org name but got { ehr_org_names } \n Sorted: { sorted } " ,
271+ )
271272
272273 def test_list_has_correct_orgs (self ):
273274 url = reverse ("fhir-organizationaffiliation-list" )
@@ -277,7 +278,7 @@ def test_list_has_correct_orgs(self):
277278
278279 valid_ids = [str (org .id ) for org in self .orgs ]
279280
280- self .assertEqual (ids , valid_ids )
281+ self .assertEqual (sorted ( ids ), sorted ( valid_ids ) )
281282
282283 def test_list_does_not_have_incorrect_orgs (self ):
283284 url = reverse ("fhir-organizationaffiliation-list" )
0 commit comments