Skip to content

Commit

Permalink
renaming based on new standars
Browse files Browse the repository at this point in the history
  • Loading branch information
matusdrobuliak66 committed Jan 6, 2025
1 parent 5608d0c commit 75e4f01
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ..security.decorators import permission_required
from ..utils_aiohttp import envelope_json_response
from ..wallets._handlers import WalletsPathParams
from . import _licensed_items_checkouts_api
from . import _licensed_items_checkouts_service
from ._exceptions_handlers import handle_plugin_requests_exceptions
from ._licensed_items_checkouts_models import (
LicensedItemCheckoutGet,
Expand Down Expand Up @@ -49,7 +49,7 @@ async def get_licensed_item_checkout(request: web.Request):
)

checkout_item: LicensedItemCheckoutGet = (
await _licensed_items_checkouts_api.get_licensed_item_checkout(
await _licensed_items_checkouts_service.get_licensed_item_checkout(
app=request.app,
product_name=req_ctx.product_name,
user_id=req_ctx.user_id,
Expand Down Expand Up @@ -87,16 +87,14 @@ async def list_licensed_item_checkouts_for_wallet(request: web.Request):
)
)

result: LicensedItemCheckoutGetPage = (
await _licensed_items_checkouts_api.list_licensed_items_checkouts_for_wallet(
app=request.app,
product_name=req_ctx.product_name,
user_id=req_ctx.user_id,
wallet_id=path_params.wallet_id,
offset=query_params.offset,
limit=query_params.limit,
order_by=OrderBy.model_construct(**query_params.order_by.model_dump()),
)
result: LicensedItemCheckoutGetPage = await _licensed_items_checkouts_service.list_licensed_items_checkouts_for_wallet(
app=request.app,
product_name=req_ctx.product_name,
user_id=req_ctx.user_id,
wallet_id=path_params.wallet_id,
offset=query_params.offset,
limit=query_params.limit,
order_by=OrderBy.model_construct(**query_params.order_by.model_dump()),
)

get_page = LicensedItemCheckoutRestGetPage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ..security.decorators import permission_required
from ..utils_aiohttp import envelope_json_response
from ..wallets._handlers import WalletsPathParams
from . import _licensed_items_purchases_api
from . import _licensed_items_purchases_service
from ._exceptions_handlers import handle_plugin_requests_exceptions
from ._models import (
LicensedItemsPurchasesListQueryParams,
Expand All @@ -47,7 +47,7 @@ async def get_licensed_item_purchase(request: web.Request):
)

licensed_item_purchase_get: LicensedItemPurchaseGet = (
await _licensed_items_purchases_api.get_licensed_item_purchase(
await _licensed_items_purchases_service.get_licensed_item_purchase(
app=request.app,
product_name=req_ctx.product_name,
user_id=req_ctx.user_id,
Expand Down Expand Up @@ -75,7 +75,7 @@ async def list_wallet_licensed_items_purchases(request: web.Request):
)

licensed_item_purchase_get_page: LicensedItemPurchaseGetPage = (
await _licensed_items_purchases_api.list_licensed_items_purchases(
await _licensed_items_purchases_service.list_licensed_items_purchases(
app=request.app,
product_name=req_ctx.product_name,
user_id=req_ctx.user_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ..login.decorators import login_required
from ..security.decorators import permission_required
from ..utils_aiohttp import envelope_json_response
from . import _licensed_items_api
from . import _licensed_items_service
from ._exceptions_handlers import handle_plugin_requests_exceptions
from ._models import (
LicensedItemsBodyParams,
Expand All @@ -47,7 +47,7 @@ async def list_licensed_items(request: web.Request):
)

licensed_item_get_page: LicensedItemGetPage = (
await _licensed_items_api.list_licensed_items(
await _licensed_items_service.list_licensed_items(
app=request.app,
product_name=req_ctx.product_name,
offset=query_params.offset,
Expand Down Expand Up @@ -81,10 +81,12 @@ async def get_licensed_item(request: web.Request):
req_ctx = LicensedItemsRequestContext.model_validate(request)
path_params = parse_request_path_parameters_as(LicensedItemsPathParams, request)

licensed_item_get: LicensedItemGet = await _licensed_items_api.get_licensed_item(
app=request.app,
licensed_item_id=path_params.licensed_item_id,
product_name=req_ctx.product_name,
licensed_item_get: LicensedItemGet = (
await _licensed_items_service.get_licensed_item(
app=request.app,
licensed_item_id=path_params.licensed_item_id,
product_name=req_ctx.product_name,
)
)

return envelope_json_response(licensed_item_get)
Expand All @@ -102,7 +104,7 @@ async def purchase_licensed_item(request: web.Request):
path_params = parse_request_path_parameters_as(LicensedItemsPathParams, request)
body_params = await parse_request_body_as(LicensedItemsBodyParams, request)

await _licensed_items_api.purchase_licensed_item(
await _licensed_items_service.purchase_licensed_item(
app=request.app,
user_id=req_ctx.user_id,
licensed_item_id=path_params.licensed_item_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from ..users.api import get_user
from ..wallets.api import get_wallet_with_available_credits_by_user_and_wallet
from ..wallets.errors import WalletNotEnoughCreditsError
from . import _licensed_items_db
from . import _licensed_items_repository
from ._models import LicensedItemsBodyParams
from .errors import LicensedItemPricingPlanMatchError

Expand All @@ -39,7 +39,7 @@ async def get_licensed_item(
product_name: ProductName,
) -> LicensedItemGet:

licensed_item_db = await _licensed_items_db.get(
licensed_item_db = await _licensed_items_repository.get(
app, licensed_item_id=licensed_item_id, product_name=product_name
)
return LicensedItemGet(
Expand All @@ -61,7 +61,7 @@ async def list_licensed_items(
limit: int,
order_by: OrderBy,
) -> LicensedItemGetPage:
total_count, licensed_item_db_list = await _licensed_items_db.list_(
total_count, licensed_item_db_list = await _licensed_items_repository.list_(
app, product_name=product_name, offset=offset, limit=limit, order_by=order_by
)
return LicensedItemGetPage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)

from ..rabbitmq import get_rabbitmq_rpc_server
from . import _licensed_items_api, _licensed_items_checkouts_api
from . import _licensed_items_checkouts_service, _licensed_items_service

router = RPCRouter()

Expand All @@ -34,7 +34,7 @@ async def get_licensed_items(
limit: int,
) -> LicensedItemGetPage:
licensed_item_get_page: LicensedItemGetPage = (
await _licensed_items_api.list_licensed_items(
await _licensed_items_service.list_licensed_items(
app=app,
product_name=product_name,
offset=offset,
Expand Down Expand Up @@ -70,7 +70,7 @@ async def checkout_licensed_item_for_wallet(
service_run_id: ServiceRunID,
) -> LicensedItemCheckoutRpcGet:
licensed_item_get = (
await _licensed_items_checkouts_api.checkout_licensed_item_for_wallet(
await _licensed_items_checkouts_service.checkout_licensed_item_for_wallet(
app,
licensed_item_id=licensed_item_id,
wallet_id=wallet_id,
Expand Down Expand Up @@ -101,7 +101,7 @@ async def release_licensed_item_for_wallet(
licensed_item_checkout_id: LicensedItemCheckoutID,
) -> LicensedItemCheckoutRpcGet:
licensed_item_get = (
await _licensed_items_checkouts_api.release_licensed_item_for_wallet(
await _licensed_items_checkouts_service.release_licensed_item_for_wallet(
app,
product_name=product_name,
user_id=user_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from ..rabbitmq import setup_rabbitmq
from . import (
_licensed_items_checkouts_handlers,
_licensed_items_handlers,
_licensed_items_purchases_handlers,
_licensed_items_checkouts_rest,
_licensed_items_purchases_rest,
_licensed_items_rest,
_rpc,
)

Expand All @@ -29,9 +29,9 @@ def setup_licenses(app: web.Application):
assert app[APP_SETTINGS_KEY].WEBSERVER_LICENSES # nosec

# routes
app.router.add_routes(_licensed_items_handlers.routes)
app.router.add_routes(_licensed_items_purchases_handlers.routes)
app.router.add_routes(_licensed_items_checkouts_handlers.routes)
app.router.add_routes(_licensed_items_rest.routes)
app.router.add_routes(_licensed_items_purchases_rest.routes)
app.router.add_routes(_licensed_items_checkouts_rest.routes)

setup_rabbitmq(app)
if app[APP_SETTINGS_KEY].WEBSERVER_RABBITMQ:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@pytest.fixture
def mock_get_licensed_items_checkouts_page(mocker: MockerFixture) -> tuple:
return mocker.patch(
"simcore_service_webserver.licenses._licensed_items_checkouts_api.licensed_items_checkouts.get_licensed_items_checkouts_page",
"simcore_service_webserver.licenses._licensed_items_checkouts_service.licensed_items_checkouts.get_licensed_items_checkouts_page",
spec=True,
return_value=_LICENSED_ITEM_CHECKOUT_PAGE,
)
Expand All @@ -42,7 +42,7 @@ def mock_get_licensed_items_checkouts_page(mocker: MockerFixture) -> tuple:
@pytest.fixture
def mock_get_licensed_item_checkout(mocker: MockerFixture) -> tuple:
return mocker.patch(
"simcore_service_webserver.licenses._licensed_items_checkouts_api.licensed_items_checkouts.get_licensed_item_checkout",
"simcore_service_webserver.licenses._licensed_items_checkouts_service.licensed_items_checkouts.get_licensed_item_checkout",
spec=True,
return_value=_LICENSED_ITEM_CHECKOUT_GET,
)
Expand All @@ -51,7 +51,7 @@ def mock_get_licensed_item_checkout(mocker: MockerFixture) -> tuple:
@pytest.fixture
def mock_get_wallet_by_user(mocker: MockerFixture) -> tuple:
return mocker.patch(
"simcore_service_webserver.licenses._licensed_items_checkouts_api.get_wallet_by_user",
"simcore_service_webserver.licenses._licensed_items_checkouts_service.get_wallet_by_user",
spec=True,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
@pytest.fixture
def mock_get_licensed_items_purchases_page(mocker: MockerFixture) -> tuple:
return mocker.patch(
"simcore_service_webserver.licenses._licensed_items_purchases_api.licensed_items_purchases.get_licensed_items_purchases_page",
"simcore_service_webserver.licenses._licensed_items_purchases_service.licensed_items_purchases.get_licensed_items_purchases_page",
spec=True,
return_value=_LICENSED_ITEM_PURCHASE_PAGE,
)
Expand All @@ -58,7 +58,7 @@ def mock_get_licensed_items_purchases_page(mocker: MockerFixture) -> tuple:
@pytest.fixture
def mock_get_licensed_item_purchase(mocker: MockerFixture) -> tuple:
return mocker.patch(
"simcore_service_webserver.licenses._licensed_items_purchases_api.licensed_items_purchases.get_licensed_item_purchase",
"simcore_service_webserver.licenses._licensed_items_purchases_service.licensed_items_purchases.get_licensed_item_purchase",
spec=True,
return_value=_LICENSED_ITEM_PURCHASE_GET,
)
Expand All @@ -67,7 +67,7 @@ def mock_get_licensed_item_purchase(mocker: MockerFixture) -> tuple:
@pytest.fixture
def mock_get_wallet_by_user(mocker: MockerFixture) -> tuple:
return mocker.patch(
"simcore_service_webserver.licenses._licensed_items_purchases_api.get_wallet_by_user",
"simcore_service_webserver.licenses._licensed_items_purchases_service.get_wallet_by_user",
spec=True,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pytest_simcore.helpers.webserver_login import UserInfoDict
from servicelib.aiohttp import status
from simcore_service_webserver.db.models import UserRole
from simcore_service_webserver.licenses import _licensed_items_db
from simcore_service_webserver.licenses import _licensed_items_repository
from simcore_service_webserver.licenses.errors import LicensedItemNotFoundError
from simcore_service_webserver.projects.models import ProjectDict

Expand All @@ -32,7 +32,7 @@ async def test_licensed_items_db_crud(
):
assert client.app

output: tuple[int, list[LicensedItemDB]] = await _licensed_items_db.list_(
output: tuple[int, list[LicensedItemDB]] = await _licensed_items_repository.list_(
client.app,
product_name=osparc_product_name,
offset=0,
Expand All @@ -41,7 +41,7 @@ async def test_licensed_items_db_crud(
)
assert output[0] == 0

licensed_item_db = await _licensed_items_db.create(
licensed_item_db = await _licensed_items_repository.create(
client.app,
product_name=osparc_product_name,
name="Model A",
Expand All @@ -50,7 +50,7 @@ async def test_licensed_items_db_crud(
)
_licensed_item_id = licensed_item_db.licensed_item_id

output: tuple[int, list[LicensedItemDB]] = await _licensed_items_db.list_(
output: tuple[int, list[LicensedItemDB]] = await _licensed_items_repository.list_(
client.app,
product_name=osparc_product_name,
offset=0,
Expand All @@ -59,35 +59,35 @@ async def test_licensed_items_db_crud(
)
assert output[0] == 1

licensed_item_db = await _licensed_items_db.get(
licensed_item_db = await _licensed_items_repository.get(
client.app,
licensed_item_id=_licensed_item_id,
product_name=osparc_product_name,
)
assert licensed_item_db.name == "Model A"

await _licensed_items_db.update(
await _licensed_items_repository.update(
client.app,
licensed_item_id=_licensed_item_id,
product_name=osparc_product_name,
updates=LicensedItemUpdateDB(name="Model B"),
)

licensed_item_db = await _licensed_items_db.get(
licensed_item_db = await _licensed_items_repository.get(
client.app,
licensed_item_id=_licensed_item_id,
product_name=osparc_product_name,
)
assert licensed_item_db.name == "Model B"

licensed_item_db = await _licensed_items_db.delete(
licensed_item_db = await _licensed_items_repository.delete(
client.app,
licensed_item_id=_licensed_item_id,
product_name=osparc_product_name,
)

with pytest.raises(LicensedItemNotFoundError):
await _licensed_items_db.get(
await _licensed_items_repository.get(
client.app,
licensed_item_id=_licensed_item_id,
product_name=osparc_product_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pytest_simcore.helpers.webserver_login import UserInfoDict
from servicelib.aiohttp import status
from simcore_service_webserver.db.models import UserRole
from simcore_service_webserver.licenses import _licensed_items_db
from simcore_service_webserver.licenses import _licensed_items_repository
from simcore_service_webserver.projects.models import ProjectDict


Expand All @@ -39,7 +39,7 @@ async def test_licensed_items_listing(
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data == []

licensed_item_db = await _licensed_items_db.create(
licensed_item_db = await _licensed_items_repository.create(
client.app,
product_name=osparc_product_name,
name="Model A",
Expand Down Expand Up @@ -67,7 +67,7 @@ async def test_licensed_items_listing(
@pytest.fixture
def mock_licensed_items_purchase_functions(mocker: MockerFixture) -> tuple:
mock_wallet_credits = mocker.patch(
"simcore_service_webserver.licenses._licensed_items_api.get_wallet_with_available_credits_by_user_and_wallet",
"simcore_service_webserver.licenses._licensed_items_service.get_wallet_with_available_credits_by_user_and_wallet",
spec=True,
return_value=WalletGetWithAvailableCredits.model_validate(
WalletGetWithAvailableCredits.model_config["json_schema_extra"]["examples"][
Expand All @@ -76,14 +76,14 @@ def mock_licensed_items_purchase_functions(mocker: MockerFixture) -> tuple:
),
)
mock_get_pricing_unit = mocker.patch(
"simcore_service_webserver.licenses._licensed_items_api.get_pricing_plan_unit",
"simcore_service_webserver.licenses._licensed_items_service.get_pricing_plan_unit",
spec=True,
return_value=PricingUnitGet.model_validate(
PricingUnitGet.model_config["json_schema_extra"]["examples"][0]
),
)
mock_create_licensed_item_purchase = mocker.patch(
"simcore_service_webserver.licenses._licensed_items_api.licensed_items_purchases.create_licensed_item_purchase",
"simcore_service_webserver.licenses._licensed_items_service.licensed_items_purchases.create_licensed_item_purchase",
spec=True,
)

Expand All @@ -106,7 +106,7 @@ async def test_licensed_items_purchase(
):
assert client.app

licensed_item_db = await _licensed_items_db.create(
licensed_item_db = await _licensed_items_repository.create(
client.app,
product_name=osparc_product_name,
name="Model A",
Expand Down
Loading

0 comments on commit 75e4f01

Please sign in to comment.