Skip to content

Commit dfd0e7a

Browse files
committed
fix tests
1 parent 3a2f201 commit dfd0e7a

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

services/web/server/tests/unit/with_dbs/04/functions/test_functions_controller_rpc.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Function,
1919
FunctionClass,
2020
FunctionUserAccessRights,
21+
RegisteredFunction,
2122
SolverFunction,
2223
)
2324
from models_library.functions_errors import (
@@ -362,16 +363,19 @@ async def test_list_functions_with_pagination_ordering(
362363
async def test_list_functions_search(
363364
client: TestClient,
364365
rpc_client: RabbitMQRPCClient,
365-
mock_function_factory: ProjectFunction,
366+
mock_function_factory: Callable[[FunctionClass], ProjectFunction],
366367
logged_user: UserInfoDict,
367368
osparc_product_name: ProductName,
368369
add_user_function_api_access_rights: None,
369370
):
370-
mock_function_dummy1 = mock_function_factory.copy()
371+
function = mock_function_factory(FunctionClass.PROJECT)
372+
assert function.function_class == FunctionClass.PROJECT
373+
374+
mock_function_dummy1 = function.model_copy()
371375
mock_function_dummy1.title = "Function TitleDummy1"
372376
mock_function_dummy1.description = "Function DescriptionDummy1"
373377

374-
mock_function_dummy2 = mock_function_factory.copy()
378+
mock_function_dummy2 = function.model_copy()
375379
mock_function_dummy2.title = "Function TitleDummy2"
376380
mock_function_dummy2.description = "Function DescriptionDummy2"
377381

@@ -439,7 +443,7 @@ async def test_list_functions_search(
439443
async def test_list_functions_with_filters(
440444
client: TestClient,
441445
rpc_client: RabbitMQRPCClient,
442-
mock_function_factory: ProjectFunction,
446+
mock_function_factory: Callable[[FunctionClass], ProjectFunction],
443447
logged_user: UserInfoDict,
444448
osparc_product_name: ProductName,
445449
add_user_function_api_access_rights: None,
@@ -450,7 +454,7 @@ async def test_list_functions_with_filters(
450454
registered_functions = [
451455
await functions_rpc.register_function(
452456
rabbitmq_rpc_client=rpc_client,
453-
function=mock_function_factory,
457+
function=mock_function_factory(FunctionClass.PROJECT),
454458
user_id=logged_user["id"],
455459
product_name=osparc_product_name,
456460
)
@@ -509,7 +513,7 @@ async def test_list_functions_with_filters(
509513
async def test_update_function_title(
510514
client: TestClient,
511515
rpc_client: RabbitMQRPCClient,
512-
mock_function_factory: ProjectFunction,
516+
mock_function_factory: Callable[[FunctionClass], RegisteredFunction],
513517
logged_user: UserInfoDict,
514518
other_logged_user: UserInfoDict,
515519
osparc_product_name: ProductName,
@@ -518,7 +522,7 @@ async def test_update_function_title(
518522
# Register the function first
519523
registered_function = await functions_rpc.register_function(
520524
rabbitmq_rpc_client=rpc_client,
521-
function=mock_function_factory,
525+
function=mock_function_factory(FunctionClass.PROJECT),
522526
user_id=logged_user["id"],
523527
product_name=osparc_product_name,
524528
)
@@ -560,15 +564,15 @@ async def test_update_function_title(
560564
async def test_update_function_description(
561565
client: TestClient,
562566
rpc_client: RabbitMQRPCClient,
563-
mock_function_factory: ProjectFunction,
567+
mock_function_factory: Callable[[FunctionClass], RegisteredFunction],
564568
logged_user: UserInfoDict,
565569
osparc_product_name: ProductName,
566570
add_user_function_api_access_rights: None,
567571
):
568572
# Register the function first
569573
registered_function = await functions_rpc.register_function(
570574
rabbitmq_rpc_client=rpc_client,
571-
function=mock_function_factory,
575+
function=mock_function_factory(FunctionClass.PROJECT),
572576
user_id=logged_user["id"],
573577
product_name=osparc_product_name,
574578
)
@@ -598,15 +602,15 @@ async def test_update_function_description(
598602
async def test_get_function_input_schema(
599603
client: TestClient,
600604
rpc_client: RabbitMQRPCClient,
601-
mock_function_factory: ProjectFunction,
605+
mock_function_factory: Callable[[FunctionClass], RegisteredFunction],
602606
logged_user: UserInfoDict,
603607
osparc_product_name: ProductName,
604608
add_user_function_api_access_rights: None,
605609
):
606610
# Register the function first
607611
registered_function = await functions_rpc.register_function(
608612
rabbitmq_rpc_client=rpc_client,
609-
function=mock_function_factory,
613+
function=mock_function_factory(FunctionClass.PROJECT),
610614
user_id=logged_user["id"],
611615
product_name=osparc_product_name,
612616
)
@@ -631,15 +635,15 @@ async def test_get_function_input_schema(
631635
async def test_get_function_output_schema(
632636
client: TestClient,
633637
rpc_client: RabbitMQRPCClient,
634-
mock_function_factory: ProjectFunction,
638+
mock_function_factory: Callable[[FunctionClass], RegisteredFunction],
635639
logged_user: UserInfoDict,
636640
osparc_product_name: ProductName,
637641
add_user_function_api_access_rights: None,
638642
):
639643
# Register the function first
640644
registered_function = await functions_rpc.register_function(
641645
rabbitmq_rpc_client=rpc_client,
642-
function=mock_function_factory,
646+
function=mock_function_factory(FunctionClass.PROJECT),
643647
user_id=logged_user["id"],
644648
product_name=osparc_product_name,
645649
)
@@ -664,7 +668,7 @@ async def test_get_function_output_schema(
664668
async def test_delete_function(
665669
client: TestClient,
666670
rpc_client: RabbitMQRPCClient,
667-
mock_function_factory: ProjectFunction,
671+
mock_function_factory: Callable[[FunctionClass], RegisteredFunction],
668672
logged_user: UserInfoDict,
669673
other_logged_user: UserInfoDict,
670674
osparc_product_name: ProductName,
@@ -673,7 +677,7 @@ async def test_delete_function(
673677
# Register the function first
674678
registered_function = await functions_rpc.register_function(
675679
rabbitmq_rpc_client=rpc_client,
676-
function=mock_function_factory,
680+
function=mock_function_factory(FunctionClass.PROJECT),
677681
user_id=logged_user["id"],
678682
product_name=osparc_product_name,
679683
)
@@ -688,14 +692,14 @@ async def test_get_function_user_permissions(
688692
client: TestClient,
689693
add_user_function_api_access_rights: None,
690694
rpc_client: RabbitMQRPCClient,
691-
mock_function_factory: ProjectFunction,
695+
mock_function_factory: Callable[[FunctionClass], RegisteredFunction],
692696
logged_user: UserInfoDict,
693697
osparc_product_name: ProductName,
694698
):
695699
# Register the function first
696700
registered_function = await functions_rpc.register_function(
697701
rabbitmq_rpc_client=rpc_client,
698-
function=mock_function_factory,
702+
function=mock_function_factory(FunctionClass.PROJECT),
699703
user_id=logged_user["id"],
700704
product_name=osparc_product_name,
701705
)

services/web/server/tests/unit/with_dbs/04/functions/test_functions_service.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# pylint: disable=unused-argument
22

3+
from collections.abc import Callable
4+
35
import pytest
46
from aiohttp.test_utils import TestClient
57
from common_library.users_enums import UserRole
6-
from models_library.api_schemas_webserver.functions import ProjectFunction
7-
from models_library.functions import FunctionGroupAccessRights
8+
from models_library.functions import (
9+
FunctionClass,
10+
FunctionGroupAccessRights,
11+
RegisteredFunction,
12+
)
813
from models_library.functions_errors import FunctionReadAccessDeniedError
914
from models_library.products import ProductName
1015
from pytest_simcore.helpers.webserver_users import UserInfoDict
@@ -24,13 +29,13 @@ async def test_set_and_remove_group_permissions(
2429
logged_user: UserInfoDict,
2530
other_logged_user: UserInfoDict,
2631
osparc_product_name: ProductName,
27-
mock_function_factory: ProjectFunction,
32+
mock_function_factory: Callable[[FunctionClass], RegisteredFunction],
2833
clean_functions: None,
2934
) -> None:
3035
# Register the function
3136
registered_function = await _functions_service.register_function(
3237
app=client.app,
33-
function=mock_function_factory,
38+
function=mock_function_factory(FunctionClass.PROJECT),
3439
user_id=logged_user["id"],
3540
product_name=osparc_product_name,
3641
)

0 commit comments

Comments
 (0)