From 6c3682c36948e560f45167af37cf9561986ff518 Mon Sep 17 00:00:00 2001 From: Mads Bisgaard Date: Mon, 30 Dec 2024 13:41:34 +0100 Subject: [PATCH] update to latest master changes --- .../api/routes/licensed_items.py | 8 ++++---- .../models/schemas/licensed_items.py | 11 ++--------- .../services_rpc/wb_api_server.py | 4 ++-- .../api-server/tests/unit/test_licensed_items.py | 15 +-------------- 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/services/api-server/src/simcore_service_api_server/api/routes/licensed_items.py b/services/api-server/src/simcore_service_api_server/api/routes/licensed_items.py index 5203c8e0344..703c731d534 100644 --- a/services/api-server/src/simcore_service_api_server/api/routes/licensed_items.py +++ b/services/api-server/src/simcore_service_api_server/api/routes/licensed_items.py @@ -1,13 +1,13 @@ from typing import Annotated, Any from fastapi import APIRouter, Depends, status +from models_library.licensed_items import LicensedItemID from pydantic import PositiveInt from ...api.dependencies.authentication import get_current_user_id, get_product_name from ...api.dependencies.webserver_rpc import get_wb_api_rpc_client from ...exceptions.service_errors_utils import DEFAULT_BACKEND_SERVICE_STATUS_CODES from ...models.pagination import Page, PaginationParams -from ...models.schemas.licensed_items import LicensedItemReleaseData from ...models.schemas.model_adapter import LicensedItemCheckoutGet, LicensedItemGet from ...services_rpc.wb_api_server import WbApiRpcClient @@ -37,7 +37,7 @@ async def get_licensed_items( @router.post( - "release", + "{licensed_item_id}/release", response_model=LicensedItemCheckoutGet, status_code=status.HTTP_200_OK, responses=_LICENSE_ITEMS_STATUS_CODES, @@ -48,10 +48,10 @@ async def release_licensed_item( web_api_rpc: Annotated[WbApiRpcClient, Depends(get_wb_api_rpc_client)], product_name: Annotated[str, Depends(get_product_name)], user_id: Annotated[PositiveInt, Depends(get_current_user_id)], - licensed_item_release_data: LicensedItemReleaseData, + licensed_item_id: LicensedItemID, ): return await web_api_rpc.release_licensed_item_for_wallet( product_name=product_name, user_id=user_id, - licensed_item_checkout_id=licensed_item_release_data.licensed_item_checkout_id, + licensed_item_checkout_id=licensed_item_id, ) diff --git a/services/api-server/src/simcore_service_api_server/models/schemas/licensed_items.py b/services/api-server/src/simcore_service_api_server/models/schemas/licensed_items.py index 1bcd088b8bd..fa084bb52fc 100644 --- a/services/api-server/src/simcore_service_api_server/models/schemas/licensed_items.py +++ b/services/api-server/src/simcore_service_api_server/models/schemas/licensed_items.py @@ -1,14 +1,7 @@ -from models_library.resource_tracker import ServiceRunId -from models_library.resource_tracker_licensed_items_checkouts import ( - LicensedItemCheckoutID, -) +from models_library.services_types import ServiceRunID from pydantic import BaseModel class LicensedItemCheckoutData(BaseModel): number_of_seats: int - service_run_id: ServiceRunId - - -class LicensedItemReleaseData(BaseModel): - licensed_item_checkout_id: LicensedItemCheckoutID + service_run_id: ServiceRunID diff --git a/services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py b/services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py index b0c832450b5..dccfa9c1f01 100644 --- a/services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py +++ b/services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py @@ -6,10 +6,10 @@ from fastapi_pagination import Page, create_page from models_library.api_schemas_webserver.licensed_items import LicensedItemGetPage from models_library.licensed_items import LicensedItemID -from models_library.resource_tracker import ServiceRunId from models_library.resource_tracker_licensed_items_checkouts import ( LicensedItemCheckoutID, ) +from models_library.services_types import ServiceRunID from models_library.users import UserID from models_library.wallets import WalletID from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient @@ -101,7 +101,7 @@ async def checkout_licensed_item_for_wallet( wallet_id: WalletID, licensed_item_id: LicensedItemID, num_of_seats: int, - service_run_id: ServiceRunId, + service_run_id: ServiceRunID, ) -> LicensedItemCheckoutGet: licensed_item_checkout_get = await _checkout_licensed_item_for_wallet( self._client, diff --git a/services/api-server/tests/unit/test_licensed_items.py b/services/api-server/tests/unit/test_licensed_items.py index 0706d65963b..cb7fbd5e58b 100644 --- a/services/api-server/tests/unit/test_licensed_items.py +++ b/services/api-server/tests/unit/test_licensed_items.py @@ -21,10 +21,6 @@ from pytest_mock import MockerFixture from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient from servicelib.rabbitmq._errors import RemoteMethodNotRegisteredError -from servicelib.rabbitmq.rpc_interfaces.resource_usage_tracker.errors import ( - CanNotCheckoutNotEnoughAvailableSeatsError, - NotEnoughAvailableSeatsError, -) from simcore_service_api_server._meta import API_VTAG from simcore_service_api_server.api.dependencies.webserver_rpc import ( get_wb_api_rpc_client, @@ -108,16 +104,7 @@ async def test_get_licensed_items_502( @pytest.mark.parametrize( "exception_to_raise,expected_api_server_status_code", [ - (None, status.HTTP_200_OK), - (NotEnoughAvailableSeatsError(), status.HTTP_409_CONFLICT), - ( - CanNotCheckoutNotEnoughAvailableSeatsError( - licensed_item_id="2e1af95b-f664-4793-81ae-5512708db3b1", - num_of_seats=3, - available_num_of_seats=2, - ), - status.HTTP_409_CONFLICT, - ), + (NotImplementedError(), status.HTTP_501_NOT_IMPLEMENTED), ], ) async def test_get_licensed_items_for_wallet(