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
14 changes: 14 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,10 @@
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
from mpt_api_client.resources.accounts.user_groups import (
AsyncUserGroupsService,
UserGroupsService,
)
from mpt_api_client.resources.accounts.users import AsyncUsersService, UsersService


Expand Down Expand Up @@ -31,6 +35,11 @@ def licensees(self) -> LicenseesService:
"""Licensees service."""
return LicenseesService(http_client=self.http_client)

@property
def user_groups(self) -> UserGroupsService:
"""User Groups service."""
return UserGroupsService(http_client=self.http_client)


class AsyncAccounts:
"""Async Accounts MPT API Module."""
Expand All @@ -57,3 +66,8 @@ def sellers(self) -> AsyncSellersService:
def licensees(self) -> AsyncLicenseesService:
"""Licensees service."""
return AsyncLicenseesService(http_client=self.http_client)

@property
def user_groups(self) -> AsyncUserGroupsService:
"""User Groups service."""
return AsyncUserGroupsService(http_client=self.http_client)
42 changes: 42 additions & 0 deletions mpt_api_client/resources/accounts/user_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCreateMixin,
AsyncDeleteMixin,
AsyncUpdateMixin,
CreateMixin,
DeleteMixin,
UpdateMixin,
)
from mpt_api_client.models import Model


class UserGroup(Model):
"""User Group resource."""


class UserGroupsServiceConfig:
"""User Groups service configuration."""

_endpoint = "/public/v1/accounts/user-groups"
_model_class = UserGroup
_collection_key = "data"


class UserGroupsService(
CreateMixin[UserGroup],
UpdateMixin[UserGroup],
DeleteMixin,
Service[UserGroup],
UserGroupsServiceConfig,
):
"""User Groups service."""


class AsyncUserGroupsService(
AsyncCreateMixin[UserGroup],
AsyncUpdateMixin[UserGroup],
AsyncDeleteMixin,
AsyncService[UserGroup],
UserGroupsServiceConfig,
):
"""Async User Groups service."""
6 changes: 6 additions & 0 deletions tests/resources/accounts/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from mpt_api_client.resources.accounts.accounts import Accounts, AsyncAccounts
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
from mpt_api_client.resources.accounts.user_groups import (
AsyncUserGroupsService,
UserGroupsService,
)
from mpt_api_client.resources.accounts.users import AsyncUsersService, UsersService


Expand All @@ -24,6 +28,7 @@ def async_accounts(async_http_client):
("users", UsersService),
("sellers", SellersService),
("licensees", LicenseesService),
("user_groups", UserGroupsService),
],
)
def test_accounts_properties(accounts, property_name, expected_service_class):
Expand All @@ -41,6 +46,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
("users", AsyncUsersService),
("sellers", AsyncSellersService),
("licensees", AsyncLicenseesService),
("user_groups", AsyncUserGroupsService),
],
)
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
Expand Down
32 changes: 32 additions & 0 deletions tests/resources/accounts/test_user_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest

from mpt_api_client.resources.accounts.user_groups import (
AsyncUserGroupsService,
UserGroupsService,
)


@pytest.fixture
def user_groups_service(http_client):
return UserGroupsService(http_client=http_client)


@pytest.fixture
def async_user_groups_service(http_client):
return AsyncUserGroupsService(http_client=http_client)


@pytest.mark.parametrize(
"method",
["get", "create", "update", "delete"],
)
def test_mixins_present(user_groups_service, method):
assert hasattr(user_groups_service, method)


@pytest.mark.parametrize(
"method",
["get", "create", "update", "delete"],
)
def test_async_mixins_present(async_user_groups_service, method):
assert hasattr(async_user_groups_service, method)