@@ -90,15 +90,15 @@ def test_list_entries_are_fhir_endpoints(self):
9090 bundle = response .data ["results" ]
9191 self .assertGreater (len (bundle ["entry" ]), 0 )
9292
93- first_entry = bundle ["entry" ][ 0 ]
94- self .assertIn ("resource" , first_entry )
93+ for entry in bundle ["entry" ]:
94+ self .assertIn ("resource" , entry )
9595
96- endpoint_resource = first_entry ["resource" ]
97- self .assertEqual (endpoint_resource ["resourceType" ], "Endpoint" )
98- self .assertIn ("id" , endpoint_resource )
99- self .assertIn ("status" , endpoint_resource )
100- self .assertIn ("connectionType" , endpoint_resource )
101- self .assertIn ("address" , endpoint_resource )
96+ endpoint_resource = entry ["resource" ]
97+ self .assertEqual (endpoint_resource ["resourceType" ], "Endpoint" )
98+ self .assertIn ("id" , endpoint_resource )
99+ self .assertIn ("status" , endpoint_resource )
100+ self .assertIn ("connectionType" , endpoint_resource )
101+ self .assertIn ("address" , endpoint_resource )
102102
103103 # Pagination tests
104104 def test_pagination_custom_page_size (self ):
@@ -124,10 +124,11 @@ def test_filter_by_name(self):
124124
125125 self .assertGreater (len (bundle ["entry" ]), 0 )
126126
127- first_endpoint = bundle ["entry" ][0 ]["resource" ]
127+ for entry in bundle ["entry" ]:
128+ endpoint = entry ["resource" ]
128129
129- self .assertIn ("name" , first_endpoint )
130- self .assertIn ("Kansas City" , first_endpoint ["name" ])
130+ self .assertIn ("name" , endpoint )
131+ self .assertIn ("Kansas City Psychiatric Group " , endpoint ["name" ])
131132
132133 def test_filter_by_connection_type (self ):
133134 connection_type = "hl7-fhir-rest"
@@ -139,11 +140,12 @@ def test_filter_by_connection_type(self):
139140 entries = bundle .get ("entry" , [])
140141 self .assertGreater (len (entries ), 0 )
141142
142- first_endpoint = entries [0 ]["resource" ]
143- self .assertIn ("connectionType" , first_endpoint )
143+ for entry in bundle ["entry" ]:
144+ endpoint = entry ["resource" ]
145+ self .assertIn ("connectionType" , endpoint )
144146
145- code = first_endpoint ["connectionType" ]["code" ]
146- self .assertEqual (connection_type , code )
147+ code = endpoint ["connectionType" ]["code" ]
148+ self .assertEqual (connection_type , code )
147149
148150 def test_filter_by_payload_type (self ):
149151 payload_type = "ccda-structuredBody:1.1"
@@ -155,11 +157,12 @@ def test_filter_by_payload_type(self):
155157 entries = bundle .get ("entry" , [])
156158 self .assertGreater (len (entries ), 0 )
157159
158- first_endpoint = entries [0 ]["resource" ]
159- self .assertIn ("payloadType" , first_endpoint )
160+ for entry in bundle ["entry" ]:
161+ endpoint = entry ["resource" ]
162+ self .assertIn ("payloadType" , endpoint )
160163
161- code = first_endpoint ["payloadType" ][0 ]["coding" ][0 ]["display" ]
162- self .assertEqual (payload_type , code )
164+ code = endpoint ["payloadType" ][0 ]["coding" ][0 ]["display" ]
165+ self .assertEqual (payload_type , code )
163166
164167 def test_filter_returns_empty_for_nonexistent_name (self ):
165168 response = self .client .get (self .list_url , {"name" : "NonexistentEndpointName12345" })
@@ -171,10 +174,7 @@ def test_filter_returns_empty_for_nonexistent_name(self):
171174
172175 # Retrieve tests
173176 def test_retrieve_specific_endpoint (self ):
174- list_response = self .client .get (self .list_url , {"page_size" : 1 })
175- first_endpoint = list_response .data ["results" ]["entry" ][0 ]["resource" ]
176-
177- endpoint_id = first_endpoint ["id" ]
177+ endpoint_id = str (self .endpoints [0 ].endpoint_instance .id )
178178 detail_url = reverse ("fhir-endpoint-detail" , args = [endpoint_id ])
179179
180180 response = self .client .get (detail_url )
@@ -194,9 +194,3 @@ def test_retrieve_nonexistent_endpoint(self):
194194
195195 self .assertEqual (response .status_code , status .HTTP_404_NOT_FOUND )
196196
197- def test_retrieve_single_endpoint (self ):
198- id = self .endpoints [0 ].endpoint_instance .id
199- url = reverse ("fhir-endpoint-detail" , args = [id ])
200- response = self .client .get (url )
201- self .assertEqual (response .status_code , status .HTTP_200_OK )
202- self .assertEqual (response .data ["id" ], str (id ))
0 commit comments