Skip to content

Commit

Permalink
update to latest master changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgaard-itis committed Dec 30, 2024
1 parent 7d4ace4 commit 6c3682c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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,
)
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 1 addition & 14 deletions services/api-server/tests/unit/test_licensed_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 6c3682c

Please sign in to comment.