Skip to content

Commit e80c818

Browse files
committed
Update seeding for Catalog
1 parent edf2b00 commit e80c818

37 files changed

+830
-920
lines changed

mpt_api_client/resources/catalog/products.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ class ProductsServiceConfig:
6565

6666

6767
class ProductsService(
68-
CreateFileMixin[Model],
69-
UpdateFileMixin[Model],
70-
PublishableMixin[Model],
68+
CreateFileMixin[Product],
69+
UpdateFileMixin[Product],
70+
PublishableMixin[Product],
7171
GetMixin[Product],
7272
DeleteMixin,
7373
CollectionMixin[Product],
@@ -128,9 +128,9 @@ def update_settings(self, product_id: str, settings: ResourceData) -> Product:
128128

129129

130130
class AsyncProductsService(
131-
AsyncCreateFileMixin[Model],
132-
AsyncUpdateFileMixin[Model],
133-
AsyncPublishableMixin[Model],
131+
AsyncCreateFileMixin[Product],
132+
AsyncUpdateFileMixin[Product],
133+
AsyncPublishableMixin[Product],
134134
AsyncGetMixin[Product],
135135
AsyncDeleteMixin,
136136
AsyncCollectionMixin[Product],

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ per-file-ignores = [
131131
"tests/e2e/accounts/*.py: WPS430 WPS202",
132132
"tests/e2e/catalog/*.py: WPS202 WPS421",
133133
"tests/e2e/catalog/items/*.py: WPS110 WPS202",
134+
"tests/seed/catalog/test_product.py: WPS202 WPS204 WPS219",
134135
"tests/*: WPS432 WPS202",
135-
"seed/accounts/*.py: WPS453",
136+
"seed/*: WPS404",
137+
"seed/accounts/*.py: WPS204 WPS404 WPS453",
138+
"seed/catalog/product.py: WPS202 WPS204 WPS217 WPS201 WPS213 WPS404"
136139
]
137140

138141
[tool.ruff]

seed/accounts/api_tokens.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import logging
22
import os
33

4-
from dependency_injector.wiring import inject
4+
from dependency_injector.wiring import Provide, inject
55

66
from mpt_api_client import AsyncMPTClient
77
from mpt_api_client.resources.accounts.api_tokens import ApiToken
8+
from seed.container import Container
89
from seed.context import Context
9-
from seed.defaults import DEFAULT_CONTEXT, DEFAULT_MPT_OPERATIONS
1010

1111
logger = logging.getLogger(__name__)
1212

1313

1414
@inject
1515
async def get_api_token(
16-
context: Context = DEFAULT_CONTEXT,
17-
mpt_ops: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
16+
context: Context = Provide[Container.context],
17+
mpt_ops: AsyncMPTClient = Provide[Container.mpt_operations],
1818
) -> ApiToken | None:
1919
"""Get API token from context or fetch from API."""
2020
api_token_id = context.get_string("accounts.api_token.id")
@@ -34,7 +34,7 @@ async def get_api_token(
3434

3535
@inject
3636
def build_api_token_data(
37-
context: Context = DEFAULT_CONTEXT,
37+
context: Context = Provide[Container.context],
3838
) -> dict[str, object]:
3939
"""Get API token data dictionary for creation."""
4040
account_id = os.getenv("CLIENT_ACCOUNT_ID")
@@ -50,8 +50,8 @@ def build_api_token_data(
5050

5151
@inject
5252
async def init_api_token(
53-
context: Context = DEFAULT_CONTEXT,
54-
mpt_ops: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
53+
context: Context = Provide[Container.context],
54+
mpt_ops: AsyncMPTClient = Provide[Container.mpt_operations],
5555
) -> ApiToken:
5656
"""Get or create API token."""
5757
api_token = await get_api_token(context=context, mpt_ops=mpt_ops)

seed/accounts/buyer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
import os
33
import pathlib
44

5-
from dependency_injector.wiring import inject
5+
from dependency_injector.wiring import Provide, inject
66

77
from mpt_api_client import AsyncMPTClient
88
from mpt_api_client.resources.accounts.buyers import Buyer
9+
from seed.container import Container
910
from seed.context import Context
10-
from seed.defaults import DEFAULT_CONTEXT, DEFAULT_MPT_OPERATIONS
1111

1212
logger = logging.getLogger(__name__)
1313

14-
icon = pathlib.Path("seed/data/logo.png").resolve()
14+
icon = pathlib.Path(__file__).parent.parent / "data/logo.png"
1515

1616

1717
@inject
1818
async def get_buyer(
19-
context: Context = DEFAULT_CONTEXT,
20-
mpt_operations: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
19+
context: Context = Provide[Container.context],
20+
mpt_operations: AsyncMPTClient = Provide[Container.mpt_operations],
2121
) -> Buyer | None:
2222
"""Get buyer from context or fetch from API."""
2323
buyer_id = context.get_string("accounts.buyer.id")
@@ -36,7 +36,7 @@ async def get_buyer(
3636

3737

3838
@inject
39-
def build_buyer_data(context: Context = DEFAULT_CONTEXT) -> dict[str, object]:
39+
def build_buyer_data(context: Context = Provide[Container.context]) -> dict[str, object]:
4040
"""Build buyer data dictionary for creation."""
4141
buyer_account_id = os.getenv("CLIENT_ACCOUNT_ID")
4242
if not buyer_account_id:
@@ -65,8 +65,8 @@ def build_buyer_data(context: Context = DEFAULT_CONTEXT) -> dict[str, object]:
6565

6666
@inject
6767
async def init_buyer(
68-
context: Context = DEFAULT_CONTEXT,
69-
mpt_operations: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
68+
context: Context = Provide[Container.context],
69+
mpt_operations: AsyncMPTClient = Provide[Container.mpt_operations],
7070
) -> Buyer:
7171
"""Get or create buyer."""
7272
buyer = await get_buyer(context=context, mpt_operations=mpt_operations)

seed/accounts/licensee.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import os
33
import pathlib
44

5-
from dependency_injector.wiring import inject
5+
from dependency_injector.wiring import Provide, inject
66

77
from mpt_api_client import AsyncMPTClient
88
from mpt_api_client.resources.accounts.licensees import Licensee
9+
from seed.container import Container
910
from seed.context import Context
10-
from seed.defaults import DEFAULT_CONTEXT, DEFAULT_MPT_CLIENT
1111

1212
logger = logging.getLogger(__name__)
1313

@@ -16,8 +16,8 @@
1616

1717
@inject
1818
async def get_licensee(
19-
context: Context = DEFAULT_CONTEXT,
20-
mpt_client: AsyncMPTClient = DEFAULT_MPT_CLIENT,
19+
context: Context = Provide[Container.context],
20+
mpt_client: AsyncMPTClient = Provide[Container.mpt_client],
2121
) -> Licensee | None:
2222
"""Get licensee from context or fetch from API."""
2323
licensee_id = context.get_string("accounts.licensee.id")
@@ -37,7 +37,7 @@ async def get_licensee(
3737

3838
@inject
3939
def build_licensee_data( # noqa: WPS238
40-
context: Context = DEFAULT_CONTEXT,
40+
context: Context = Provide[Container.context],
4141
) -> dict[str, object]:
4242
"""Get licensee data dictionary for creation."""
4343
account_id = os.getenv("CLIENT_ACCOUNT_ID")
@@ -76,8 +76,8 @@ def build_licensee_data( # noqa: WPS238
7676

7777
@inject
7878
async def init_licensee(
79-
context: Context = DEFAULT_CONTEXT,
80-
mpt_client: AsyncMPTClient = DEFAULT_MPT_CLIENT,
79+
context: Context = Provide[Container.context],
80+
mpt_client: AsyncMPTClient = Provide[Container.mpt_client],
8181
) -> Licensee:
8282
"""Get or create licensee."""
8383
licensee = await get_licensee(context=context, mpt_client=mpt_client)

seed/accounts/module.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import logging
22

3-
from dependency_injector.wiring import inject
3+
from dependency_injector.wiring import Provide, inject
44

55
from mpt_api_client import AsyncMPTClient
66
from mpt_api_client.resources.accounts.modules import Module
77
from mpt_api_client.rql.query_builder import RQLQuery
8+
from seed.container import Container
89
from seed.context import Context
9-
from seed.defaults import DEFAULT_CONTEXT, DEFAULT_MPT_OPERATIONS
1010

1111
logger = logging.getLogger(__name__)
1212

1313

1414
@inject
1515
async def get_module(
16-
context: Context = DEFAULT_CONTEXT,
17-
mpt_operations: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
16+
context: Context = Provide[Container.context],
17+
mpt_operations: AsyncMPTClient = Provide[Container.mpt_operations],
1818
) -> Module | None:
1919
"""Get module from context or fetch from API."""
2020
module_id = context.get_string("accounts.module.id")
@@ -34,8 +34,8 @@ async def get_module(
3434

3535
@inject
3636
async def refresh_module(
37-
context: Context = DEFAULT_CONTEXT,
38-
mpt_operations: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
37+
context: Context = Provide[Container.context],
38+
mpt_operations: AsyncMPTClient = Provide[Container.mpt_operations],
3939
) -> Module | None:
4040
"""Refresh module in context (always fetch)."""
4141
module = await get_module(context=context, mpt_operations=mpt_operations)

seed/accounts/seller.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
import logging
33
import uuid
44

5-
from dependency_injector.wiring import inject
5+
from dependency_injector.wiring import Provide, inject
66

77
from mpt_api_client import AsyncMPTClient
88
from mpt_api_client.resources.accounts.sellers import Seller
9+
from seed.container import Container
910
from seed.context import Context
10-
from seed.defaults import DEFAULT_CONTEXT, DEFAULT_MPT_OPERATIONS
1111

1212
logger = logging.getLogger(__name__)
1313

1414

1515
@inject
1616
async def get_seller(
17-
context: Context = DEFAULT_CONTEXT,
18-
mpt_operations: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
17+
context: Context = Provide[Container.context],
18+
mpt_operations: AsyncMPTClient = Provide[Container.mpt_operations],
1919
) -> Seller | None:
2020
"""Get seller from context or fetch from API."""
2121
seller_id = context.get_string("accounts.seller.id")
@@ -54,8 +54,8 @@ def build_seller_data(external_id: str | None = None) -> dict[str, object]:
5454

5555
@inject
5656
async def init_seller(
57-
context: Context = DEFAULT_CONTEXT,
58-
mpt_operations: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
57+
context: Context = Provide[Container.context],
58+
mpt_operations: AsyncMPTClient = Provide[Container.mpt_operations],
5959
) -> Seller | None:
6060
"""Get or create seller. Returns Seller if successful, None otherwise."""
6161
seller = await get_seller(context=context, mpt_operations=mpt_operations)

seed/accounts/user_group.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
import logging
33
import os
44

5-
from dependency_injector.wiring import inject
5+
from dependency_injector.wiring import Provide, inject
66

77
from mpt_api_client import AsyncMPTClient
88
from mpt_api_client.resources.accounts.user_groups import UserGroup
9+
from seed.container import Container
910
from seed.context import Context
10-
from seed.defaults import DEFAULT_CONTEXT, DEFAULT_MPT_OPERATIONS
1111

1212
logger = logging.getLogger(__name__)
1313

1414

1515
@inject
1616
async def get_user_group(
17-
context: Context = DEFAULT_CONTEXT,
18-
mpt_operations: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
17+
context: Context = Provide[Container.context],
18+
mpt_operations: AsyncMPTClient = Provide[Container.mpt_operations],
1919
) -> UserGroup | None:
2020
"""Get user group from context or fetch from API."""
2121
user_group_id = context.get_string("accounts.user_group.id")
@@ -35,7 +35,7 @@ async def get_user_group(
3535

3636
@inject
3737
def build_user_group_data(
38-
context: Context = DEFAULT_CONTEXT,
38+
context: Context = Provide[Container.context],
3939
) -> dict[str, object]:
4040
"""Get user group data dictionary for creation."""
4141
account_id = os.getenv("CLIENT_ACCOUNT_ID")
@@ -54,8 +54,8 @@ def build_user_group_data(
5454

5555
@inject
5656
async def init_user_group(
57-
context: Context = DEFAULT_CONTEXT,
58-
mpt_operations: AsyncMPTClient = DEFAULT_MPT_OPERATIONS,
57+
context: Context = Provide[Container.context],
58+
mpt_operations: AsyncMPTClient = Provide[Container.mpt_operations],
5959
) -> UserGroup | None:
6060
"""Get or create user group."""
6161
user_group = await get_user_group(context=context, mpt_operations=mpt_operations)

seed/assets/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)