Skip to content

Commit

Permalink
PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
matusdrobuliak66 committed Dec 5, 2024
1 parent 68ecfe5 commit 9896a91
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/models-library/src/models_library/licensed_items.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from datetime import datetime
from enum import auto
from typing import TypeAlias
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from .products import ProductName
from .resource_tracker import PricingPlanId
from .utils.enums import StrAutoEnum

LicensedItemID: TypeAlias = str
LicensedItemID: TypeAlias = UUID


class LicensedResourceType(StrAutoEnum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,28 @@


def upgrade():
# CREATE EXTENSION pgcrypto;
op.execute(
"""
DO
$$
BEGIN
IF EXISTS(SELECT * FROM pg_available_extensions WHERE name = 'pgcrypto') THEN
-- Create the extension
CREATE EXTENSION if not exists pgcrypto;
END IF;
END
$$;
"""
)

# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"resource_tracker_licensed_items_purchases",
sa.Column(
"licensed_item_purchase_id",
postgresql.UUID(as_uuid=True),
server_default="gen_random_uuid()",
server_default=sa.text("gen_random_uuid()"),
nullable=False,
),
sa.Column("product_name", sa.String(), nullable=False),
Expand Down Expand Up @@ -61,7 +76,7 @@ def upgrade():
sa.Column(
"licensed_item_usage_id",
postgresql.UUID(as_uuid=True),
server_default="gen_random_uuid()",
server_default=sa.text("gen_random_uuid()"),
nullable=False,
),
sa.Column("licensed_item_id", sa.String(), nullable=True),
Expand Down Expand Up @@ -102,7 +117,7 @@ def upgrade():
sa.Column(
"licensed_item_id",
postgresql.UUID(as_uuid=True),
server_default="gen_random_uuid()",
server_default=sa.text("gen_random_uuid()"),
nullable=False,
),
sa.Column("name", sa.String(), nullable=False),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2404,6 +2404,7 @@ paths:
required: true
schema:
type: string
format: uuid
title: Licensed Item Id
responses:
'200':
Expand Down Expand Up @@ -2431,6 +2432,7 @@ paths:
required: true
schema:
type: string
format: uuid
title: Licensed Item Id
requestBody:
required: true
Expand Down Expand Up @@ -10011,11 +10013,12 @@ components:
properties:
licensedItemId:
type: string
format: uuid
title: Licenseditemid
name:
type: string
title: Name
licenseResourceType:
licensedResourceType:
$ref: '#/components/schemas/LicensedResourceType'
pricingPlanId:
type: integer
Expand All @@ -10034,7 +10037,7 @@ components:
required:
- licensedItemId
- name
- licenseResourceType
- licensedResourceType
- pricingPlanId
- createdAt
- modifiedAt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ async def test_licensed_items_db_crud(

# get
url = client.app.router["get_licensed_item"].url_for(
licensed_item_id=_licensed_item_id
licensed_item_id=f"{_licensed_item_id}"
)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert LicensedItemGet(**data)

# purchase
url = client.app.router["purchase_licensed_item"].url_for(
licensed_item_id=_licensed_item_id
licensed_item_id=f"{_licensed_item_id}"
)
resp = await client.post(f"{url}", json={"wallet_id": 1, "num_of_seeds": 5})
# NOTE: Not yet implemented

0 comments on commit 9896a91

Please sign in to comment.