From 9ec0c5ec2f455378d24eea0174855d0577d23442 Mon Sep 17 00:00:00 2001 From: Robert Segal Date: Thu, 2 Oct 2025 15:49:57 -0600 Subject: [PATCH] Added Accounts modules endpoints --- mpt_api_client/resources/accounts/accounts.py | 11 +++++++++ mpt_api_client/resources/accounts/modules.py | 22 ++++++++++++++++++ setup.cfg | 2 +- tests/resources/accounts/test_accounts.py | 3 +++ tests/resources/accounts/test_modules.py | 23 +++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 mpt_api_client/resources/accounts/modules.py create mode 100644 tests/resources/accounts/test_modules.py diff --git a/mpt_api_client/resources/accounts/accounts.py b/mpt_api_client/resources/accounts/accounts.py index 0335fcf0..4c97ff0e 100644 --- a/mpt_api_client/resources/accounts/accounts.py +++ b/mpt_api_client/resources/accounts/accounts.py @@ -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, @@ -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.""" @@ -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) diff --git a/mpt_api_client/resources/accounts/modules.py b/mpt_api_client/resources/accounts/modules.py new file mode 100644 index 00000000..a29505f8 --- /dev/null +++ b/mpt_api_client/resources/accounts/modules.py @@ -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.""" diff --git a/setup.cfg b/setup.cfg index 343cab29..a6ce265f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/tests/resources/accounts/test_accounts.py b/tests/resources/accounts/test_accounts.py index 500c0758..d6738786 100644 --- a/tests/resources/accounts/test_accounts.py +++ b/tests/resources/accounts/test_accounts.py @@ -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, @@ -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): @@ -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): diff --git a/tests/resources/accounts/test_modules.py b/tests/resources/accounts/test_modules.py new file mode 100644 index 00000000..dd36ff11 --- /dev/null +++ b/tests/resources/accounts/test_modules.py @@ -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)