|
2 | 2 | # pylint: disable=unused-argument |
3 | 3 |
|
4 | 4 | import datetime |
| 5 | +from collections.abc import Callable |
5 | 6 | from uuid import uuid4 |
6 | 7 |
|
7 | 8 | import pytest |
8 | 9 | from aiohttp.test_utils import TestClient |
9 | 10 | from common_library.users_enums import UserRole |
10 | 11 | from faker import Faker |
11 | 12 | from models_library.api_schemas_webserver.functions import ( |
12 | | - ProjectFunction, |
13 | 13 | ProjectFunctionJob, |
14 | 14 | ) |
15 | 15 | from models_library.functions import ( |
| 16 | + Function, |
16 | 17 | FunctionClass, |
17 | 18 | FunctionJobCollection, |
18 | 19 | FunctionJobStatus, |
@@ -47,15 +48,15 @@ async def test_register_get_delete_function_job( |
47 | 48 | client: TestClient, |
48 | 49 | add_user_function_api_access_rights: None, |
49 | 50 | rpc_client: RabbitMQRPCClient, |
50 | | - mock_function: ProjectFunction, |
| 51 | + mock_function_factory: Callable[[FunctionClass], Function], |
51 | 52 | logged_user: UserInfoDict, |
52 | 53 | other_logged_user: UserInfoDict, |
53 | 54 | osparc_product_name: ProductName, |
54 | 55 | ): |
55 | 56 | # Register the function first |
56 | 57 | registered_function = await functions_rpc.register_function( |
57 | 58 | rabbitmq_rpc_client=rpc_client, |
58 | | - function=mock_function, |
| 59 | + function=mock_function_factory(FunctionClass.PROJECT), |
59 | 60 | user_id=logged_user["id"], |
60 | 61 | product_name=osparc_product_name, |
61 | 62 | ) |
@@ -175,14 +176,14 @@ async def test_list_function_jobs( |
175 | 176 | client: TestClient, |
176 | 177 | add_user_function_api_access_rights: None, |
177 | 178 | rpc_client: RabbitMQRPCClient, |
178 | | - mock_function: ProjectFunction, |
| 179 | + mock_function_factory: Callable[[FunctionClass], Function], |
179 | 180 | logged_user: UserInfoDict, |
180 | 181 | osparc_product_name: ProductName, |
181 | 182 | ): |
182 | 183 | # Register the function first |
183 | 184 | registered_function = await functions_rpc.register_function( |
184 | 185 | rabbitmq_rpc_client=rpc_client, |
185 | | - function=mock_function, |
| 186 | + function=mock_function_factory(FunctionClass.PROJECT), |
186 | 187 | user_id=logged_user["id"], |
187 | 188 | product_name=osparc_product_name, |
188 | 189 | ) |
@@ -227,21 +228,21 @@ async def test_list_function_jobs( |
227 | 228 | async def test_list_function_jobs_filtering( |
228 | 229 | client: TestClient, |
229 | 230 | rpc_client: RabbitMQRPCClient, |
230 | | - mock_function: ProjectFunction, |
| 231 | + mock_function_factory: Callable[[FunctionClass], Function], |
231 | 232 | logged_user: UserInfoDict, |
232 | 233 | osparc_product_name: ProductName, |
233 | 234 | add_user_function_api_access_rights: None, |
234 | 235 | ): |
235 | 236 | # Register the function first |
236 | 237 | first_registered_function = await functions_rpc.register_function( |
237 | 238 | rabbitmq_rpc_client=rpc_client, |
238 | | - function=mock_function, |
| 239 | + function=mock_function_factory(FunctionClass.PROJECT), |
239 | 240 | user_id=logged_user["id"], |
240 | 241 | product_name=osparc_product_name, |
241 | 242 | ) |
242 | 243 | second_registered_function = await functions_rpc.register_function( |
243 | 244 | rabbitmq_rpc_client=rpc_client, |
244 | | - function=mock_function, |
| 245 | + function=mock_function_factory(FunctionClass.PROJECT), |
245 | 246 | user_id=logged_user["id"], |
246 | 247 | product_name=osparc_product_name, |
247 | 248 | ) |
@@ -376,13 +377,13 @@ async def test_find_cached_function_jobs( |
376 | 377 | logged_user: UserInfoDict, |
377 | 378 | other_logged_user: UserInfoDict, |
378 | 379 | osparc_product_name: ProductName, |
379 | | - mock_function: ProjectFunction, |
| 380 | + mock_function_factory: Callable[[FunctionClass], Function], |
380 | 381 | clean_functions: None, |
381 | 382 | ): |
382 | 383 | # Register the function first |
383 | 384 | registered_function = await functions_rpc.register_function( |
384 | 385 | rabbitmq_rpc_client=rpc_client, |
385 | | - function=mock_function, |
| 386 | + function=mock_function_factory(FunctionClass.PROJECT), |
386 | 387 | user_id=logged_user["id"], |
387 | 388 | product_name=osparc_product_name, |
388 | 389 | ) |
@@ -448,13 +449,13 @@ async def test_patch_registered_function_jobs( |
448 | 449 | logged_user: UserInfoDict, |
449 | 450 | other_logged_user: UserInfoDict, |
450 | 451 | osparc_product_name: ProductName, |
451 | | - mock_function: ProjectFunction, |
| 452 | + mock_function_factory: Callable[[FunctionClass], Function], |
452 | 453 | clean_functions: None, |
453 | 454 | ): |
454 | 455 |
|
455 | 456 | registered_function = await functions_rpc.register_function( |
456 | 457 | rabbitmq_rpc_client=rpc_client, |
457 | | - function=mock_function, |
| 458 | + function=mock_function_factory(FunctionClass.PROJECT), |
458 | 459 | user_id=logged_user["id"], |
459 | 460 | product_name=osparc_product_name, |
460 | 461 | ) |
@@ -511,13 +512,13 @@ async def test_update_function_job_status( |
511 | 512 | rpc_client: RabbitMQRPCClient, |
512 | 513 | add_user_function_api_access_rights: None, |
513 | 514 | logged_user: UserInfoDict, |
514 | | - mock_function: ProjectFunction, |
| 515 | + mock_function_factory: Callable[[FunctionClass], Function], |
515 | 516 | osparc_product_name: ProductName, |
516 | 517 | ): |
517 | 518 | # Register the function first |
518 | 519 | registered_function = await functions_rpc.register_function( |
519 | 520 | rabbitmq_rpc_client=rpc_client, |
520 | | - function=mock_function, |
| 521 | + function=mock_function_factory(FunctionClass.PROJECT), |
521 | 522 | user_id=logged_user["id"], |
522 | 523 | product_name=osparc_product_name, |
523 | 524 | ) |
@@ -571,13 +572,13 @@ async def test_update_function_job_outputs( |
571 | 572 | rpc_client: RabbitMQRPCClient, |
572 | 573 | add_user_function_api_access_rights: None, |
573 | 574 | logged_user: UserInfoDict, |
574 | | - mock_function: ProjectFunction, |
| 575 | + mock_function_factory: Callable[[FunctionClass], Function], |
575 | 576 | osparc_product_name: ProductName, |
576 | 577 | ): |
577 | 578 | # Register the function first |
578 | 579 | registered_function = await functions_rpc.register_function( |
579 | 580 | rabbitmq_rpc_client=rpc_client, |
580 | | - function=mock_function, |
| 581 | + function=mock_function_factory(FunctionClass.PROJECT), |
581 | 582 | user_id=logged_user["id"], |
582 | 583 | product_name=osparc_product_name, |
583 | 584 | ) |
|
0 commit comments