2323from pytest_simcore .helpers .typing_env import EnvVarsDict
2424from respx .router import MockRouter
2525from servicelib .rabbitmq import RabbitMQRPCClient
26+ from servicelib .rabbitmq .rpc_interfaces .catalog import services as catalog_rpc
2627from servicelib .rabbitmq .rpc_interfaces .catalog .errors import (
2728 CatalogForbiddenError ,
2829 CatalogItemNotFoundError ,
2930)
30- from servicelib .rabbitmq .rpc_interfaces .catalog .services import (
31- batch_get_my_services ,
32- check_for_service ,
33- get_service ,
34- list_my_service_history_paginated ,
35- list_services_paginated ,
36- update_service ,
37- )
3831
3932pytest_simcore_core_services_selection = [
4033 "rabbit" ,
@@ -118,7 +111,7 @@ async def test_rpc_list_services_paginated_with_no_services_returns_empty_page(
118111):
119112 assert app
120113
121- page = await list_services_paginated (
114+ page = await catalog_rpc . list_services_paginated (
122115 rpc_client , product_name = "not_existing_returns_no_services" , user_id = user_id
123116 )
124117 assert page .data == []
@@ -139,7 +132,7 @@ async def test_rpc_list_services_paginated_with_filters(
139132 assert app
140133
141134 # only computational services introduced by the background_sync_task_mocked
142- page = await list_services_paginated (
135+ page = await catalog_rpc . list_services_paginated (
143136 rpc_client ,
144137 product_name = product_name ,
145138 user_id = user_id ,
@@ -148,7 +141,7 @@ async def test_rpc_list_services_paginated_with_filters(
148141 assert page .meta .total == page .meta .count
149142 assert page .meta .total > 0
150143
151- page = await list_services_paginated (
144+ page = await catalog_rpc . list_services_paginated (
152145 rpc_client ,
153146 product_name = product_name ,
154147 user_id = user_id ,
@@ -157,7 +150,7 @@ async def test_rpc_list_services_paginated_with_filters(
157150 assert page .meta .total == 0
158151
159152
160- async def test_rpc_catalog_client (
153+ async def test_rpc_catalog_client_workflow (
161154 background_sync_task_mocked : None ,
162155 mocked_director_rest_api : MockRouter ,
163156 rpc_client : RabbitMQRPCClient ,
@@ -168,7 +161,7 @@ async def test_rpc_catalog_client(
168161):
169162 assert app
170163
171- page = await list_services_paginated (
164+ page = await catalog_rpc . list_services_paginated (
172165 rpc_client , product_name = product_name , user_id = user_id
173166 )
174167
@@ -177,14 +170,14 @@ async def test_rpc_catalog_client(
177170 service_version = page .data [0 ].version
178171
179172 with pytest .raises (ValidationError ):
180- await list_services_paginated (
173+ await catalog_rpc . list_services_paginated (
181174 rpc_client ,
182175 product_name = product_name ,
183176 user_id = user_id ,
184177 limit = MAXIMUM_NUMBER_OF_ITEMS_PER_PAGE + 1 ,
185178 )
186179
187- got = await get_service (
180+ got = await catalog_rpc . get_service (
188181 rpc_client ,
189182 product_name = product_name ,
190183 user_id = user_id ,
@@ -200,7 +193,7 @@ async def test_rpc_catalog_client(
200193 if (item .key == service_key and item .version == service_version )
201194 )
202195
203- updated = await update_service (
196+ updated = await catalog_rpc . update_service (
204197 rpc_client ,
205198 product_name = product_name ,
206199 user_id = user_id ,
@@ -224,7 +217,7 @@ async def test_rpc_catalog_client(
224217 assert updated .icon is not None
225218 assert not updated .classifiers
226219
227- got = await get_service (
220+ got = await catalog_rpc . get_service (
228221 rpc_client ,
229222 product_name = product_name ,
230223 user_id = user_id ,
@@ -244,7 +237,7 @@ async def test_rpc_get_service_not_found_error(
244237):
245238
246239 with pytest .raises (CatalogItemNotFoundError , match = "unknown" ):
247- await get_service (
240+ await catalog_rpc . get_service (
248241 rpc_client ,
249242 product_name = product_name ,
250243 user_id = user_id ,
@@ -263,7 +256,7 @@ async def test_rpc_get_service_validation_error(
263256):
264257
265258 with pytest .raises (ValidationError , match = "service_key" ):
266- await get_service (
259+ await catalog_rpc . get_service (
267260 rpc_client ,
268261 product_name = product_name ,
269262 user_id = user_id ,
@@ -281,7 +274,7 @@ async def test_rpc_check_for_service(
281274 user_id : UserID ,
282275):
283276 with pytest .raises (CatalogItemNotFoundError , match = "unknown" ):
284- await check_for_service (
277+ await catalog_rpc . check_for_service (
285278 rpc_client ,
286279 product_name = product_name ,
287280 user_id = user_id ,
@@ -309,7 +302,7 @@ async def test_rpc_get_service_access_rights(
309302 service_key = ServiceKey ("simcore/services/comp/test-api-rpc-service-0" )
310303 service_version = ServiceVersion ("0.0.0" )
311304
312- service = await get_service (
305+ service = await catalog_rpc . get_service (
313306 rpc_client ,
314307 product_name = product_name ,
315308 user_id = user_id ,
@@ -325,7 +318,7 @@ async def test_rpc_get_service_access_rights(
325318
326319 # other_user does not have EXECUTE access -----------------
327320 with pytest .raises (CatalogForbiddenError , match = service_key ):
328- await get_service (
321+ await catalog_rpc . get_service (
329322 rpc_client ,
330323 product_name = product_name ,
331324 user_id = other_user ["id" ],
@@ -335,7 +328,7 @@ async def test_rpc_get_service_access_rights(
335328
336329 # other_user does not have WRITE access
337330 with pytest .raises (CatalogForbiddenError , match = service_key ):
338- await update_service (
331+ await catalog_rpc . update_service (
339332 rpc_client ,
340333 product_name = product_name ,
341334 user_id = other_user ["id" ],
@@ -349,7 +342,7 @@ async def test_rpc_get_service_access_rights(
349342
350343 # user_id gives "x access" to other_user ------------
351344 assert service .access_rights is not None
352- await update_service (
345+ await catalog_rpc . update_service (
353346 rpc_client ,
354347 product_name = product_name ,
355348 user_id = user_id ,
@@ -367,7 +360,7 @@ async def test_rpc_get_service_access_rights(
367360 )
368361
369362 # other user can now GET but NOT UPDATE
370- await get_service (
363+ await catalog_rpc . get_service (
371364 rpc_client ,
372365 product_name = product_name ,
373366 user_id = other_user ["id" ],
@@ -376,7 +369,7 @@ async def test_rpc_get_service_access_rights(
376369 )
377370
378371 with pytest .raises (CatalogForbiddenError , match = service_key ):
379- await update_service (
372+ await catalog_rpc . update_service (
380373 rpc_client ,
381374 product_name = product_name ,
382375 user_id = other_user ["id" ],
@@ -390,7 +383,7 @@ async def test_rpc_get_service_access_rights(
390383
391384 # user_id gives "xw access" to other_user ------------------
392385 assert service .access_rights is not None
393- await update_service (
386+ await catalog_rpc . update_service (
394387 rpc_client ,
395388 product_name = product_name ,
396389 user_id = user_id ,
@@ -408,7 +401,7 @@ async def test_rpc_get_service_access_rights(
408401 )
409402
410403 # other_user can now update and get
411- await update_service (
404+ await catalog_rpc . update_service (
412405 rpc_client ,
413406 product_name = product_name ,
414407 user_id = other_user ["id" ],
@@ -419,7 +412,7 @@ async def test_rpc_get_service_access_rights(
419412 "description" : "bar" ,
420413 },
421414 )
422- updated_service = await get_service (
415+ updated_service = await catalog_rpc . get_service (
423416 rpc_client ,
424417 product_name = product_name ,
425418 user_id = other_user ["id" ],
@@ -482,7 +475,7 @@ async def test_rpc_batch_get_my_services(
482475 (other_service_key , other_service_version ),
483476 ]
484477
485- my_services = await batch_get_my_services (
478+ my_services = await catalog_rpc . batch_get_my_services (
486479 rpc_client ,
487480 product_name = product_name ,
488481 user_id = user_id ,
@@ -569,7 +562,7 @@ async def test_rpc_list_my_service_history_paginated(
569562 await services_db_tables_injector (fake_releases + unrelated_releases )
570563
571564 # Call the RPC function
572- page = await list_my_service_history_paginated (
565+ page = await catalog_rpc . list_my_service_history_paginated (
573566 rpc_client ,
574567 product_name = product_name ,
575568 user_id = user_id ,
@@ -611,11 +604,8 @@ async def test_rpc_get_service_ports_successful_retrieval(
611604 )
612605 await services_db_tables_injector ([fake_service ])
613606
614- # Import the get_service_ports function from the client
615- from servicelib .rabbitmq .rpc_interfaces .catalog .services import get_service_ports
616-
617607 # Call the RPC function to get service ports
618- ports = await get_service_ports (
608+ ports = await catalog_rpc . get_service_ports (
619609 rpc_client ,
620610 product_name = product_name ,
621611 user_id = user_id ,
@@ -643,15 +633,12 @@ async def test_rpc_get_service_ports_not_found(
643633 """Tests that appropriate error is raised when service does not exist"""
644634 assert app
645635
646- # Import the get_service_ports function from the client
647- from servicelib .rabbitmq .rpc_interfaces .catalog .services import get_service_ports
648-
649636 service_version = "1.0.0"
650637 non_existent_key = "simcore/services/comp/non-existent-service"
651638
652639 # Test service not found scenario
653640 with pytest .raises (CatalogItemNotFoundError , match = "non-existent-service" ):
654- await get_service_ports (
641+ await catalog_rpc . get_service_ports (
655642 rpc_client ,
656643 product_name = product_name ,
657644 user_id = user_id ,
@@ -674,9 +661,6 @@ async def test_rpc_get_service_ports_permission_denied(
674661 """Tests that appropriate error is raised when user doesn't have permission"""
675662 assert app
676663
677- # Import the get_service_ports function from the client
678- from servicelib .rabbitmq .rpc_interfaces .catalog .services import get_service_ports
679-
680664 # Create a service with restricted access
681665 restricted_service_key = "simcore/services/comp/restricted-service"
682666 service_version = "1.0.0"
@@ -699,7 +683,7 @@ async def test_rpc_get_service_ports_permission_denied(
699683
700684 # Attempt to access without permission
701685 with pytest .raises (CatalogForbiddenError ):
702- await get_service_ports (
686+ await catalog_rpc . get_service_ports (
703687 rpc_client ,
704688 product_name = product_name ,
705689 user_id = UserID ("different-user" ), # Use a different user ID
@@ -719,12 +703,9 @@ async def test_rpc_get_service_ports_validation_error(
719703 """Tests validation error handling for invalid service key format"""
720704 assert app
721705
722- # Import the get_service_ports function from the client
723- from servicelib .rabbitmq .rpc_interfaces .catalog .services import get_service_ports
724-
725706 # Test with invalid service key format
726707 with pytest .raises (ValidationError , match = "service_key" ):
727- await get_service_ports (
708+ await catalog_rpc . get_service_ports (
728709 rpc_client ,
729710 product_name = product_name ,
730711 user_id = user_id ,
0 commit comments