@@ -179,40 +179,36 @@ async def test_fetch_latest_entity_success_async(self) -> None:
179179 submission = Submission (entity_id = ENTITY_ID , evaluation_id = EVALUATION_ID )
180180
181181 # WHEN I call _fetch_latest_entity with a mocked successful response
182- with patch .object (
183- self .syn ,
184- "rest_get_async" ,
182+ with patch (
183+ "synapseclient.api.entity_services.get_entity" ,
185184 new_callable = AsyncMock ,
186185 return_value = self .get_example_entity_response (),
187- ) as mock_rest_get :
186+ ) as mock_get_entity :
188187 entity_info = await submission ._fetch_latest_entity (synapse_client = self .syn )
189188
190189 # THEN it should return the entity information
191190 assert entity_info ["id" ] == ENTITY_ID
192191 assert entity_info ["etag" ] == ETAG
193192 assert entity_info ["versionNumber" ] == VERSION_NUMBER
194- mock_rest_get .assert_called_once_with (f"/entity/{ ENTITY_ID } " )
193+ mock_get_entity .assert_called_once_with (
194+ entity_id = ENTITY_ID , synapse_client = self .syn
195+ )
195196
196197 @pytest .mark .asyncio
197198 async def test_fetch_latest_entity_docker_repository_async (self ) -> None :
198199 # GIVEN a submission with a Docker repository entity_id
199200 submission = Submission (entity_id = ENTITY_ID , evaluation_id = EVALUATION_ID )
200201
201202 # WHEN I call _fetch_latest_entity with mocked Docker repository responses
202- with patch .object (
203- self .syn ,
204- "rest_get_async" ,
203+ with patch (
204+ "synapseclient.api.entity_services.get_entity" ,
205205 new_callable = AsyncMock ,
206- ) as mock_rest_get :
207- # Configure the mock to return different responses for different URLs
208- def side_effect (url ):
209- if url == f"/entity/{ ENTITY_ID } " :
210- return self .get_example_docker_entity_response ()
211- elif url == f"/entity/{ ENTITY_ID } /dockerTag" :
212- return self .get_example_docker_tag_response ()
213-
214- mock_rest_get .side_effect = side_effect
215-
206+ return_value = self .get_example_docker_entity_response (),
207+ ) as mock_get_entity , patch (
208+ "synapseclient.api.docker_commit_services.get_docker_tag" ,
209+ new_callable = AsyncMock ,
210+ return_value = self .get_example_docker_tag_response (),
211+ ) as mock_get_docker_tag :
216212 entity_info = await submission ._fetch_latest_entity (synapse_client = self .syn )
217213
218214 # THEN it should return the entity information with latest docker tag info
@@ -224,33 +220,29 @@ def side_effect(url):
224220 assert entity_info ["digest" ] == "sha256:latest456abc789"
225221 assert entity_info ["createdOn" ] == "2024-06-01T15:30:00.000Z"
226222
227- # Verify both API calls were made
228- expected_calls = [
229- call (f"/entity/{ ENTITY_ID } " ),
230- call (f"/entity/{ ENTITY_ID } /dockerTag" ),
231- ]
232- mock_rest_get .assert_has_calls (expected_calls )
223+ # Verify both API functions were called
224+ mock_get_entity .assert_called_once_with (
225+ entity_id = ENTITY_ID , synapse_client = self .syn
226+ )
227+ mock_get_docker_tag .assert_called_once_with (
228+ entity_id = ENTITY_ID , synapse_client = self .syn
229+ )
233230
234231 @pytest .mark .asyncio
235232 async def test_fetch_latest_entity_docker_empty_results_async (self ) -> None :
236233 # GIVEN a submission with a Docker repository entity_id
237234 submission = Submission (entity_id = ENTITY_ID , evaluation_id = EVALUATION_ID )
238235
239236 # WHEN I call _fetch_latest_entity with empty docker tag results
240- with patch .object (
241- self .syn ,
242- "rest_get_async" ,
237+ with patch (
238+ "synapseclient.api.entity_services.get_entity" ,
243239 new_callable = AsyncMock ,
244- ) as mock_rest_get :
245- # Configure the mock to return empty docker tag results
246- def side_effect (url ):
247- if url == f"/entity/{ ENTITY_ID } " :
248- return self .get_example_docker_entity_response ()
249- elif url == f"/entity/{ ENTITY_ID } /dockerTag" :
250- return {"totalNumberOfResults" : 0 , "results" : []}
251-
252- mock_rest_get .side_effect = side_effect
253-
240+ return_value = self .get_example_docker_entity_response (),
241+ ) as mock_get_entity , patch (
242+ "synapseclient.api.docker_commit_services.get_docker_tag" ,
243+ new_callable = AsyncMock ,
244+ return_value = {"totalNumberOfResults" : 0 , "results" : []},
245+ ) as mock_get_docker_tag :
254246 entity_info = await submission ._fetch_latest_entity (synapse_client = self .syn )
255247
256248 # THEN it should return the entity information without docker tag info
@@ -262,33 +254,44 @@ def side_effect(url):
262254 assert "digest" not in entity_info
263255 assert "createdOn" not in entity_info
264256
257+ # Verify both API functions were called
258+ mock_get_entity .assert_called_once_with (
259+ entity_id = ENTITY_ID , synapse_client = self .syn
260+ )
261+ mock_get_docker_tag .assert_called_once_with (
262+ entity_id = ENTITY_ID , synapse_client = self .syn
263+ )
264+
265265 @pytest .mark .asyncio
266266 async def test_fetch_latest_entity_docker_complex_tag_selection_async (self ) -> None :
267267 # GIVEN a submission with a Docker repository with multiple tags
268268 submission = Submission (entity_id = ENTITY_ID , evaluation_id = EVALUATION_ID )
269269
270270 # WHEN I call _fetch_latest_entity with multiple docker tags with different dates
271- with patch .object (
272- self .syn ,
273- "rest_get_async" ,
271+ with patch (
272+ "synapseclient.api.entity_services.get_entity" ,
274273 new_callable = AsyncMock ,
275- ) as mock_rest_get :
276- # Configure the mock to return complex docker tag results
277- def side_effect (url ):
278- if url == f"/entity/{ ENTITY_ID } " :
279- return self .get_example_docker_entity_response ()
280- elif url == f"/entity/{ ENTITY_ID } /dockerTag" :
281- return self .get_complex_docker_tag_response ()
282-
283- mock_rest_get .side_effect = side_effect
284-
274+ return_value = self .get_example_docker_entity_response (),
275+ ) as mock_get_entity , patch (
276+ "synapseclient.api.docker_commit_services.get_docker_tag" ,
277+ new_callable = AsyncMock ,
278+ return_value = self .get_complex_docker_tag_response (),
279+ ) as mock_get_docker_tag :
285280 entity_info = await submission ._fetch_latest_entity (synapse_client = self .syn )
286281
287282 # THEN it should select the tag with the latest createdOn timestamp (v3.0)
288283 assert entity_info ["tag" ] == "v3.0"
289284 assert entity_info ["digest" ] == "sha256:version3"
290285 assert entity_info ["createdOn" ] == "2024-08-15T12:00:00.000Z"
291286
287+ # Verify both API functions were called
288+ mock_get_entity .assert_called_once_with (
289+ entity_id = ENTITY_ID , synapse_client = self .syn
290+ )
291+ mock_get_docker_tag .assert_called_once_with (
292+ entity_id = ENTITY_ID , synapse_client = self .syn
293+ )
294+
292295 @pytest .mark .asyncio
293296 async def test_store_async_success (self ) -> None :
294297 # GIVEN a submission with valid data
0 commit comments