|
7 | 7 | from decimal import Decimal |
8 | 8 |
|
9 | 9 | import pytest |
10 | | -from models_library.api_schemas_webserver import WEBSERVER_RPC_NAMESPACE |
11 | | -from models_library.api_schemas_webserver.products import CreditResultRpcGet |
12 | 10 | from models_library.products import ProductName |
13 | | -from models_library.rabbitmq_basic_types import RPCMethodName |
14 | | -from pydantic import TypeAdapter |
15 | 11 | from pytest_mock import MockerFixture |
16 | 12 | from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict |
17 | 13 | from pytest_simcore.helpers.typing_env import EnvVarsDict |
18 | 14 | from pytest_simcore.helpers.webserver_login import UserInfoDict |
19 | 15 | from servicelib.rabbitmq import RabbitMQRPCClient, RPCServerError |
| 16 | +from servicelib.rabbitmq.rpc_interfaces.webserver.products import get_credit_amount |
20 | 17 | from settings_library.rabbit import RabbitSettings |
21 | 18 | from simcore_postgres_database.models.users import UserRole |
22 | 19 | from simcore_service_webserver.application_settings import ApplicationSettings |
@@ -69,28 +66,26 @@ async def test_get_credit_amount( |
69 | 66 | osparc_product_name: ProductName, |
70 | 67 | logged_user: UserInfoDict, |
71 | 68 | ): |
72 | | - result = await rpc_client.request( |
73 | | - WEBSERVER_RPC_NAMESPACE, |
74 | | - TypeAdapter(RPCMethodName).validate_python("get_credit_amount"), |
| 69 | + # Using the new client function for s4l |
| 70 | + credit_result = await get_credit_amount( |
| 71 | + rpc_client, |
75 | 72 | dollar_amount=Decimal(900), |
76 | 73 | product_name="s4l", |
77 | 74 | ) |
78 | | - credit_result = CreditResultRpcGet.model_validate(result) |
79 | 75 | assert credit_result.credit_amount == 100 |
80 | 76 |
|
81 | | - result = await rpc_client.request( |
82 | | - WEBSERVER_RPC_NAMESPACE, |
83 | | - TypeAdapter(RPCMethodName).validate_python("get_credit_amount"), |
| 77 | + # Using the new client function for tis |
| 78 | + credit_result = await get_credit_amount( |
| 79 | + rpc_client, |
84 | 80 | dollar_amount=Decimal(900), |
85 | 81 | product_name="tis", |
86 | 82 | ) |
87 | | - credit_result = CreditResultRpcGet.model_validate(result) |
88 | 83 | assert credit_result.credit_amount == 180 |
89 | 84 |
|
| 85 | + # Testing the error case |
90 | 86 | with pytest.raises(RPCServerError) as exc_info: |
91 | | - await rpc_client.request( |
92 | | - WEBSERVER_RPC_NAMESPACE, |
93 | | - TypeAdapter(RPCMethodName).validate_python("get_credit_amount"), |
| 87 | + await get_credit_amount( |
| 88 | + rpc_client, |
94 | 89 | dollar_amount=Decimal(900), |
95 | 90 | product_name="osparc", |
96 | 91 | ) |
|
0 commit comments