Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions mpt_api_client/resources/accounts/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
from mpt_api_client.resources.accounts.api_tokens import ApiTokensService, AsyncApiTokensService
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
from mpt_api_client.resources.accounts.user_groups import (
AsyncUserGroupsService,
Expand Down Expand Up @@ -46,6 +47,11 @@ def api_tokens(self) -> ApiTokensService:
"""API Tokens service."""
return ApiTokensService(http_client=self.http_client)

@property
def modules(self) -> ModulesService:
"""Modules service."""
return ModulesService(http_client=self.http_client)


class AsyncAccounts:
"""Async Accounts MPT API Module."""
Expand Down Expand Up @@ -82,3 +88,8 @@ def user_groups(self) -> AsyncUserGroupsService:
def api_tokens(self) -> AsyncApiTokensService:
"""API Tokens service."""
return AsyncApiTokensService(http_client=self.http_client)

@property
def modules(self) -> AsyncModulesService:
"""Modules service."""
return AsyncModulesService(http_client=self.http_client)
22 changes: 22 additions & 0 deletions mpt_api_client/resources/accounts/modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.models import Model


class Module(Model):
"""Module Model."""


class ModulesServiceConfig:
"""Modules Service Configuration."""

_endpoint = "/public/v1/accounts/modules"
_model_class = Module
_collection_key = "data"


class ModulesService(Service[Module], ModulesServiceConfig):
"""Modules Service."""


class AsyncModulesService(AsyncService[Module], ModulesServiceConfig):
"""Asynchronous Modules Service."""
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ per-file-ignores =
mpt_api_client/mpt_client.py: WPS214 WPS235
mpt_api_client/http/mixins.py: WPS202
mpt_api_client/resources/*: WPS215
mpt_api_client/resources/accounts/*.py: WPS202 WPS215
mpt_api_client/resources/accounts/*.py: WPS202 WPS215 WPS214
mpt_api_client/resources/billing/*.py: WPS202 WPS204 WPS214 WPS215
mpt_api_client/resources/catalog/*.py: WPS110 WPS214 WPS215
mpt_api_client/resources/catalog/products.py: WPS204 WPS214 WPS215
Expand Down
3 changes: 3 additions & 0 deletions tests/resources/accounts/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
AsyncApiTokensService,
)
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
from mpt_api_client.resources.accounts.user_groups import (
AsyncUserGroupsService,
Expand Down Expand Up @@ -34,6 +35,7 @@ def async_accounts(async_http_client):
("licensees", LicenseesService),
("user_groups", UserGroupsService),
("api_tokens", ApiTokensService),
("modules", ModulesService),
],
)
def test_accounts_properties(accounts, property_name, expected_service_class):
Expand All @@ -53,6 +55,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
("licensees", AsyncLicenseesService),
("user_groups", AsyncUserGroupsService),
("api_tokens", AsyncApiTokensService),
("modules", AsyncModulesService),
],
)
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
Expand Down
23 changes: 23 additions & 0 deletions tests/resources/accounts/test_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest

from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService


@pytest.fixture
def module_service(http_client):
return ModulesService(http_client=http_client)


@pytest.fixture
def async_module_service(http_client):
return AsyncModulesService(http_client=http_client)


@pytest.mark.parametrize("method", ["get"])
def test_modules_mixins_present(module_service, method):
assert hasattr(module_service, method)


@pytest.mark.parametrize("method", ["get"])
def test_async_modules_mixins_present(async_module_service, method):
assert hasattr(async_module_service, method)