1212from common_library .users_enums import UserRole
1313from models_library .products import ProductName
1414from models_library .projects import ProjectID
15+ from models_library .rest_pagination import (
16+ DEFAULT_NUMBER_OF_ITEMS_PER_PAGE ,
17+ PageLimitInt ,
18+ PageOffsetInt ,
19+ )
1520from models_library .rpc .webserver .projects import (
1621 ListProjectsMarkedAsJobRpcFilters ,
1722 MetadataFilterItem ,
1823 PageRpcProjectJobRpcGet ,
1924 ProjectJobRpcGet ,
2025)
26+ from models_library .users import UserID
2127from pydantic import ValidationError
2228from pytest_simcore .helpers .monkeypatch_envs import setenvs_from_dict
2329from pytest_simcore .helpers .typing_env import EnvVarsDict
2834 ProjectForbiddenRpcError ,
2935 ProjectNotFoundRpcError ,
3036)
37+ from servicelib .rabbitmq .rpc_interfaces .webserver .v1 import WebServerRpcClient
3138from settings_library .rabbit import RabbitSettings
3239from simcore_service_webserver .application_settings import ApplicationSettings
3340from simcore_service_webserver .projects .models import ProjectDict
@@ -94,18 +101,148 @@ async def test_rpc_client_mark_project_as_job(
94101 )
95102
96103
97- async def test_rpc_client_list_my_projects_marked_as_jobs (
104+ @pytest .fixture (params = ["free_functions" , "v1_client" ])
105+ async def projects_interface (
106+ request : pytest .FixtureRequest ,
98107 rpc_client : RabbitMQRPCClient ,
108+ ):
109+ """Fixture that provides both free function and v1 client interfaces for projects."""
110+ if request .param == "free_functions" :
111+ # Return a namespace object that mimics the free function interface
112+ class FreeFunction :
113+ @staticmethod
114+ async def list_projects_marked_as_jobs (
115+ rpc_client : RabbitMQRPCClient ,
116+ * ,
117+ product_name : ProductName ,
118+ user_id : UserID ,
119+ offset : PageOffsetInt = 0 ,
120+ limit : PageLimitInt = DEFAULT_NUMBER_OF_ITEMS_PER_PAGE ,
121+ filters : ListProjectsMarkedAsJobRpcFilters | None = None ,
122+ ) -> PageRpcProjectJobRpcGet :
123+ return await projects_rpc .list_projects_marked_as_jobs (
124+ rpc_client = rpc_client ,
125+ product_name = product_name ,
126+ user_id = user_id ,
127+ offset = offset ,
128+ limit = limit ,
129+ filters = filters ,
130+ )
131+
132+ @staticmethod
133+ async def mark_project_as_job (
134+ rpc_client : RabbitMQRPCClient ,
135+ * ,
136+ product_name : ProductName ,
137+ user_id : UserID ,
138+ project_uuid : ProjectID ,
139+ job_parent_resource_name : str ,
140+ storage_assets_deleted : bool ,
141+ ) -> None :
142+ return await projects_rpc .mark_project_as_job (
143+ rpc_client = rpc_client ,
144+ product_name = product_name ,
145+ user_id = user_id ,
146+ project_uuid = project_uuid ,
147+ job_parent_resource_name = job_parent_resource_name ,
148+ storage_assets_deleted = storage_assets_deleted ,
149+ )
150+
151+ @staticmethod
152+ async def get_project_marked_as_job (
153+ rpc_client : RabbitMQRPCClient ,
154+ * ,
155+ product_name : ProductName ,
156+ user_id : UserID ,
157+ project_uuid : ProjectID ,
158+ job_parent_resource_name : str ,
159+ ) -> ProjectJobRpcGet :
160+ return await projects_rpc .get_project_marked_as_job (
161+ rpc_client = rpc_client ,
162+ product_name = product_name ,
163+ user_id = user_id ,
164+ project_uuid = project_uuid ,
165+ job_parent_resource_name = job_parent_resource_name ,
166+ )
167+
168+ return FreeFunction (), rpc_client
169+
170+ assert request .param == "v1_client"
171+ # Return the v1 client interface
172+ v1_client = WebServerRpcClient (rpc_client )
173+
174+ class V1ClientAdapter :
175+ def __init__ (self , client : WebServerRpcClient ):
176+ self ._client = client
177+
178+ async def list_projects_marked_as_jobs (
179+ self ,
180+ rpc_client : RabbitMQRPCClient , # Not used in v1, kept for compatibility
181+ * ,
182+ product_name : ProductName ,
183+ user_id : UserID ,
184+ offset : PageOffsetInt = 0 ,
185+ limit : PageLimitInt = DEFAULT_NUMBER_OF_ITEMS_PER_PAGE ,
186+ filters : ListProjectsMarkedAsJobRpcFilters | None = None ,
187+ ) -> PageRpcProjectJobRpcGet :
188+ return await self ._client .projects .list_projects_marked_as_jobs (
189+ product_name = product_name ,
190+ user_id = user_id ,
191+ offset = offset ,
192+ limit = limit ,
193+ filters = filters ,
194+ )
195+
196+ async def mark_project_as_job (
197+ self ,
198+ rpc_client : RabbitMQRPCClient , # Not used in v1, kept for compatibility
199+ * ,
200+ product_name : ProductName ,
201+ user_id : UserID ,
202+ project_uuid : ProjectID ,
203+ job_parent_resource_name : str ,
204+ storage_assets_deleted : bool ,
205+ ) -> None :
206+ return await self ._client .projects .mark_project_as_job (
207+ product_name = product_name ,
208+ user_id = user_id ,
209+ project_uuid = project_uuid ,
210+ job_parent_resource_name = job_parent_resource_name ,
211+ storage_assets_deleted = storage_assets_deleted ,
212+ )
213+
214+ async def get_project_marked_as_job (
215+ self ,
216+ rpc_client : RabbitMQRPCClient , # Not used in v1, kept for compatibility
217+ * ,
218+ product_name : ProductName ,
219+ user_id : UserID ,
220+ project_uuid : ProjectID ,
221+ job_parent_resource_name : str ,
222+ ) -> ProjectJobRpcGet :
223+ return await self ._client .projects .get_project_marked_as_job (
224+ product_name = product_name ,
225+ user_id = user_id ,
226+ project_uuid = project_uuid ,
227+ job_parent_resource_name = job_parent_resource_name ,
228+ )
229+
230+ return V1ClientAdapter (v1_client ), rpc_client
231+
232+
233+ async def test_rpc_client_list_my_projects_marked_as_jobs (
234+ projects_interface : tuple ,
99235 product_name : ProductName ,
100236 logged_user : UserInfoDict ,
101237 user_project : ProjectDict ,
102238):
239+ interface , rpc_client = projects_interface
103240 project_uuid = ProjectID (user_project ["uuid" ])
104241 user_id = logged_user ["id" ]
105242
106243 # Mark the project as a job first
107- await projects_rpc .mark_project_as_job (
108- rpc_client = rpc_client ,
244+ await interface .mark_project_as_job (
245+ rpc_client ,
109246 product_name = product_name ,
110247 user_id = user_id ,
111248 project_uuid = project_uuid ,
@@ -114,8 +251,8 @@ async def test_rpc_client_list_my_projects_marked_as_jobs(
114251 )
115252
116253 # List projects marked as jobs
117- page : PageRpcProjectJobRpcGet = await projects_rpc .list_projects_marked_as_jobs (
118- rpc_client = rpc_client ,
254+ page : PageRpcProjectJobRpcGet = await interface .list_projects_marked_as_jobs (
255+ rpc_client ,
119256 product_name = product_name ,
120257 user_id = user_id ,
121258 filters = ListProjectsMarkedAsJobRpcFilters (
0 commit comments