|
11 | 11 | import pytest |
12 | 12 | from aiohttp.test_utils import TestClient |
13 | 13 | from faker import Faker |
14 | | -from models_library.api_schemas_resource_usage_tracker.pricing_plans import ( |
15 | | - PricingPlanGet, |
16 | | - PricingPlanToServiceGet, |
17 | | - PricingUnitGet, |
18 | | -) |
19 | 14 | from models_library.resource_tracker import PricingPlanClassification |
20 | 15 | from pytest_mock import MockerFixture |
21 | 16 | from pytest_simcore.helpers.assert_checks import assert_status |
|
24 | 19 | from simcore_service_webserver.db.models import UserRole |
25 | 20 |
|
26 | 21 |
|
27 | | -@pytest.fixture |
28 | | -def mock_rpc_resource_usage_tracker_service_api( |
29 | | - mocker: MockerFixture, faker: Faker |
30 | | -) -> dict[str, MagicMock]: |
31 | | - return { |
32 | | - ## Pricing plans |
33 | | - "list_pricing_plans": mocker.patch( |
34 | | - "simcore_service_webserver.resource_usage._pricing_plans_admin_api.pricing_plans.list_pricing_plans", |
35 | | - autospec=True, |
36 | | - return_value=[ |
37 | | - PricingPlanGet.model_validate( |
38 | | - PricingPlanGet.model_config["json_schema_extra"]["examples"][0], |
39 | | - ) |
40 | | - ], |
41 | | - ), |
42 | | - "get_pricing_plan": mocker.patch( |
43 | | - "simcore_service_webserver.resource_usage._pricing_plans_admin_api.pricing_plans.get_pricing_plan", |
44 | | - autospec=True, |
45 | | - return_value=PricingPlanGet.model_validate( |
46 | | - PricingPlanGet.model_config["json_schema_extra"]["examples"][0], |
47 | | - ), |
48 | | - ), |
49 | | - "create_pricing_plan": mocker.patch( |
50 | | - "simcore_service_webserver.resource_usage._pricing_plans_admin_api.pricing_plans.create_pricing_plan", |
51 | | - autospec=True, |
52 | | - return_value=PricingPlanGet.model_validate( |
53 | | - PricingPlanGet.model_config["json_schema_extra"]["examples"][0], |
54 | | - ), |
55 | | - ), |
56 | | - "update_pricing_plan": mocker.patch( |
57 | | - "simcore_service_webserver.resource_usage._pricing_plans_admin_api.pricing_plans.update_pricing_plan", |
58 | | - autospec=True, |
59 | | - return_value=PricingPlanGet.model_validate( |
60 | | - PricingPlanGet.model_config["json_schema_extra"]["examples"][0], |
61 | | - ), |
62 | | - ), |
63 | | - ## Pricing units |
64 | | - "get_pricing_unit": mocker.patch( |
65 | | - "simcore_service_webserver.resource_usage._pricing_plans_admin_api.pricing_units.get_pricing_unit", |
66 | | - autospec=True, |
67 | | - return_value=PricingUnitGet.model_validate( |
68 | | - PricingUnitGet.model_config["json_schema_extra"]["examples"][0], |
69 | | - ), |
70 | | - ), |
71 | | - "create_pricing_unit": mocker.patch( |
72 | | - "simcore_service_webserver.resource_usage._pricing_plans_admin_api.pricing_units.create_pricing_unit", |
73 | | - autospec=True, |
74 | | - return_value=PricingUnitGet.model_validate( |
75 | | - PricingUnitGet.model_config["json_schema_extra"]["examples"][0], |
76 | | - ), |
77 | | - ), |
78 | | - "update_pricing_unit": mocker.patch( |
79 | | - "simcore_service_webserver.resource_usage._pricing_plans_admin_api.pricing_units.update_pricing_unit", |
80 | | - autospec=True, |
81 | | - return_value=PricingUnitGet.model_validate( |
82 | | - PricingUnitGet.model_config["json_schema_extra"]["examples"][0], |
83 | | - ), |
84 | | - ), |
85 | | - ## Pricing plan to service |
86 | | - "list_connected_services_to_pricing_plan_by_pricing_plan": mocker.patch( |
87 | | - "simcore_service_webserver.resource_usage._pricing_plans_admin_api.pricing_plans.list_connected_services_to_pricing_plan_by_pricing_plan", |
88 | | - autospec=True, |
89 | | - return_value=[ |
90 | | - PricingPlanToServiceGet.model_validate( |
91 | | - PricingPlanToServiceGet.model_config["json_schema_extra"][ |
92 | | - "examples" |
93 | | - ][0], |
94 | | - ) |
95 | | - ], |
96 | | - ), |
97 | | - "connect_service_to_pricing_plan": mocker.patch( |
98 | | - "simcore_service_webserver.resource_usage._pricing_plans_admin_api.pricing_plans.connect_service_to_pricing_plan", |
99 | | - autospec=True, |
100 | | - return_value=PricingPlanToServiceGet.model_validate( |
101 | | - PricingPlanToServiceGet.model_config["json_schema_extra"]["examples"][ |
102 | | - 0 |
103 | | - ], |
104 | | - ), |
105 | | - ), |
106 | | - } |
107 | | - |
108 | | - |
109 | 22 | @pytest.fixture |
110 | 23 | def mock_catalog_client(mocker: MockerFixture, faker: Faker) -> dict[str, MagicMock]: |
111 | 24 | return { |
@@ -137,11 +50,13 @@ async def test_get_admin_pricing_endpoints_user_role_access( |
137 | 50 | ): |
138 | 51 | ## Pricing plans |
139 | 52 |
|
140 | | - url = client.app.router["list_pricing_plans"].url_for() |
| 53 | + url = client.app.router["list_pricing_plans_for_admin_user"].url_for() |
141 | 54 | resp = await client.get(f"{url}") |
142 | 55 | await assert_status(resp, expected) |
143 | 56 |
|
144 | | - url = client.app.router["get_pricing_plan"].url_for(pricing_plan_id="1") |
| 57 | + url = client.app.router["get_pricing_plan_for_admin_user"].url_for( |
| 58 | + pricing_plan_id="1" |
| 59 | + ) |
145 | 60 | resp = await client.get(f"{url}") |
146 | 61 | await assert_status(resp, expected) |
147 | 62 |
|
|
0 commit comments