@@ -172,10 +172,8 @@ def test_semantic_search_basic(self, integration_client: OMOPHub) -> None:
172172 "myocardial infarction" , page_size = 5
173173 )
174174
175- # SDK may return data wrapped in 'results' key
176- results = result .get ("results" , result )
177- if isinstance (results , dict ) and "results" in results :
178- results = results ["results" ]
175+ # SDK may return data wrapped in 'results' key or as a list
176+ results = extract_data (result , "results" )
179177
180178 # Should have results
181179 assert isinstance (results , list )
@@ -195,9 +193,7 @@ def test_semantic_search_with_filters(self, integration_client: OMOPHub) -> None
195193 page_size = 10 ,
196194 )
197195
198- results = result .get ("results" , result )
199- if isinstance (results , dict ) and "results" in results :
200- results = results ["results" ]
196+ results = extract_data (result , "results" )
201197
202198 # If results exist, verify filters applied
203199 if len (results ) > 0 :
@@ -214,13 +210,8 @@ def test_semantic_search_with_threshold(self, integration_client: OMOPHub) -> No
214210 "heart attack" , threshold = 0.8 , page_size = 20
215211 )
216212
217- results_low = result_low .get ("results" , [])
218- results_high = result_high .get ("results" , [])
219-
220- if isinstance (results_low , dict ) and "results" in results_low :
221- results_low = results_low ["results" ]
222- if isinstance (results_high , dict ) and "results" in results_high :
223- results_high = results_high ["results" ]
213+ results_low = extract_data (result_low , "results" )
214+ results_high = extract_data (result_high , "results" )
224215
225216 # Guard: skip test if no results to compare
226217 if not results_low :
@@ -256,9 +247,7 @@ def test_similar_by_concept_id(self, integration_client: OMOPHub) -> None:
256247 )
257248
258249 # Should have similar_concepts key or be a list
259- similar = result .get ("similar_concepts" , result )
260- if isinstance (similar , dict ) and "similar_concepts" in similar :
261- similar = similar ["similar_concepts" ]
250+ similar = extract_data (result , "similar_concepts" )
262251
263252 assert isinstance (similar , list )
264253 # If results exist, verify structure
@@ -272,9 +261,7 @@ def test_similar_by_query(self, integration_client: OMOPHub) -> None:
272261 query = "elevated blood glucose" , page_size = 5
273262 )
274263
275- similar = result .get ("similar_concepts" , result )
276- if isinstance (similar , dict ) and "similar_concepts" in similar :
277- similar = similar ["similar_concepts" ]
264+ similar = extract_data (result , "similar_concepts" )
278265
279266 assert isinstance (similar , list )
280267
@@ -306,9 +293,7 @@ def test_similar_with_vocabulary_filter(self, integration_client: OMOPHub) -> No
306293 page_size = 10 ,
307294 )
308295
309- similar = result .get ("similar_concepts" , [])
310- if isinstance (similar , dict ) and "similar_concepts" in similar :
311- similar = similar ["similar_concepts" ]
296+ similar = extract_data (result , "similar_concepts" )
312297
313298 # If results, all should be from SNOMED
314299 for concept in similar :
0 commit comments