Skip to content

Commit b83abf8

Browse files
authored
[MPT-14099] Added Accounts modules endpoints (#80)
Added Accounts modules endpoints https://softwareone.atlassian.net/browse/MPT-14099
2 parents 29f5865 + 9ec0c5e commit b83abf8

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

mpt_api_client/resources/accounts/accounts.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
33
from mpt_api_client.resources.accounts.api_tokens import ApiTokensService, AsyncApiTokensService
44
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
5+
from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService
56
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
67
from mpt_api_client.resources.accounts.user_groups import (
78
AsyncUserGroupsService,
@@ -46,6 +47,11 @@ def api_tokens(self) -> ApiTokensService:
4647
"""API Tokens service."""
4748
return ApiTokensService(http_client=self.http_client)
4849

50+
@property
51+
def modules(self) -> ModulesService:
52+
"""Modules service."""
53+
return ModulesService(http_client=self.http_client)
54+
4955

5056
class AsyncAccounts:
5157
"""Async Accounts MPT API Module."""
@@ -82,3 +88,8 @@ def user_groups(self) -> AsyncUserGroupsService:
8288
def api_tokens(self) -> AsyncApiTokensService:
8389
"""API Tokens service."""
8490
return AsyncApiTokensService(http_client=self.http_client)
91+
92+
@property
93+
def modules(self) -> AsyncModulesService:
94+
"""Modules service."""
95+
return AsyncModulesService(http_client=self.http_client)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.models import Model
3+
4+
5+
class Module(Model):
6+
"""Module Model."""
7+
8+
9+
class ModulesServiceConfig:
10+
"""Modules Service Configuration."""
11+
12+
_endpoint = "/public/v1/accounts/modules"
13+
_model_class = Module
14+
_collection_key = "data"
15+
16+
17+
class ModulesService(Service[Module], ModulesServiceConfig):
18+
"""Modules Service."""
19+
20+
21+
class AsyncModulesService(AsyncService[Module], ModulesServiceConfig):
22+
"""Asynchronous Modules Service."""

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ per-file-ignores =
3535
mpt_api_client/mpt_client.py: WPS214 WPS235
3636
mpt_api_client/http/mixins.py: WPS202
3737
mpt_api_client/resources/*: WPS215
38-
mpt_api_client/resources/accounts/*.py: WPS202 WPS215
38+
mpt_api_client/resources/accounts/*.py: WPS202 WPS215 WPS214
3939
mpt_api_client/resources/billing/*.py: WPS202 WPS204 WPS214 WPS215
4040
mpt_api_client/resources/catalog/*.py: WPS110 WPS214 WPS215
4141
mpt_api_client/resources/catalog/products.py: WPS204 WPS214 WPS215

tests/resources/accounts/test_accounts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
AsyncApiTokensService,
88
)
99
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
10+
from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService
1011
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
1112
from mpt_api_client.resources.accounts.user_groups import (
1213
AsyncUserGroupsService,
@@ -34,6 +35,7 @@ def async_accounts(async_http_client):
3435
("licensees", LicenseesService),
3536
("user_groups", UserGroupsService),
3637
("api_tokens", ApiTokensService),
38+
("modules", ModulesService),
3739
],
3840
)
3941
def test_accounts_properties(accounts, property_name, expected_service_class):
@@ -53,6 +55,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
5355
("licensees", AsyncLicenseesService),
5456
("user_groups", AsyncUserGroupsService),
5557
("api_tokens", AsyncApiTokensService),
58+
("modules", AsyncModulesService),
5659
],
5760
)
5861
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService
4+
5+
6+
@pytest.fixture
7+
def module_service(http_client):
8+
return ModulesService(http_client=http_client)
9+
10+
11+
@pytest.fixture
12+
def async_module_service(http_client):
13+
return AsyncModulesService(http_client=http_client)
14+
15+
16+
@pytest.mark.parametrize("method", ["get"])
17+
def test_modules_mixins_present(module_service, method):
18+
assert hasattr(module_service, method)
19+
20+
21+
@pytest.mark.parametrize("method", ["get"])
22+
def test_async_modules_mixins_present(async_module_service, method):
23+
assert hasattr(async_module_service, method)

0 commit comments

Comments
 (0)