Skip to content

Commit 73176ea

Browse files
authored
[MPT-14086] Added Accounts user groups endpoints (#74)
Added Accounts user groups endpoints https://softwareone.atlassian.net/browse/MPT-14086
2 parents 7938167 + 1470b26 commit 73176ea

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

mpt_api_client/resources/accounts/accounts.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
33
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
44
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
5+
from mpt_api_client.resources.accounts.user_groups import (
6+
AsyncUserGroupsService,
7+
UserGroupsService,
8+
)
59
from mpt_api_client.resources.accounts.users import AsyncUsersService, UsersService
610

711

@@ -31,6 +35,11 @@ def licensees(self) -> LicenseesService:
3135
"""Licensees service."""
3236
return LicenseesService(http_client=self.http_client)
3337

38+
@property
39+
def user_groups(self) -> UserGroupsService:
40+
"""User Groups service."""
41+
return UserGroupsService(http_client=self.http_client)
42+
3443

3544
class AsyncAccounts:
3645
"""Async Accounts MPT API Module."""
@@ -57,3 +66,8 @@ def sellers(self) -> AsyncSellersService:
5766
def licensees(self) -> AsyncLicenseesService:
5867
"""Licensees service."""
5968
return AsyncLicenseesService(http_client=self.http_client)
69+
70+
@property
71+
def user_groups(self) -> AsyncUserGroupsService:
72+
"""User Groups service."""
73+
return AsyncUserGroupsService(http_client=self.http_client)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.http.mixins import (
3+
AsyncCreateMixin,
4+
AsyncDeleteMixin,
5+
AsyncUpdateMixin,
6+
CreateMixin,
7+
DeleteMixin,
8+
UpdateMixin,
9+
)
10+
from mpt_api_client.models import Model
11+
12+
13+
class UserGroup(Model):
14+
"""User Group resource."""
15+
16+
17+
class UserGroupsServiceConfig:
18+
"""User Groups service configuration."""
19+
20+
_endpoint = "/public/v1/accounts/user-groups"
21+
_model_class = UserGroup
22+
_collection_key = "data"
23+
24+
25+
class UserGroupsService(
26+
CreateMixin[UserGroup],
27+
UpdateMixin[UserGroup],
28+
DeleteMixin,
29+
Service[UserGroup],
30+
UserGroupsServiceConfig,
31+
):
32+
"""User Groups service."""
33+
34+
35+
class AsyncUserGroupsService(
36+
AsyncCreateMixin[UserGroup],
37+
AsyncUpdateMixin[UserGroup],
38+
AsyncDeleteMixin,
39+
AsyncService[UserGroup],
40+
UserGroupsServiceConfig,
41+
):
42+
"""Async User Groups service."""

tests/resources/accounts/test_accounts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
from mpt_api_client.resources.accounts.accounts import Accounts, AsyncAccounts
55
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
66
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
7+
from mpt_api_client.resources.accounts.user_groups import (
8+
AsyncUserGroupsService,
9+
UserGroupsService,
10+
)
711
from mpt_api_client.resources.accounts.users import AsyncUsersService, UsersService
812

913

@@ -24,6 +28,7 @@ def async_accounts(async_http_client):
2428
("users", UsersService),
2529
("sellers", SellersService),
2630
("licensees", LicenseesService),
31+
("user_groups", UserGroupsService),
2732
],
2833
)
2934
def test_accounts_properties(accounts, property_name, expected_service_class):
@@ -41,6 +46,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
4146
("users", AsyncUsersService),
4247
("sellers", AsyncSellersService),
4348
("licensees", AsyncLicenseesService),
49+
("user_groups", AsyncUserGroupsService),
4450
],
4551
)
4652
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.accounts.user_groups import (
4+
AsyncUserGroupsService,
5+
UserGroupsService,
6+
)
7+
8+
9+
@pytest.fixture
10+
def user_groups_service(http_client):
11+
return UserGroupsService(http_client=http_client)
12+
13+
14+
@pytest.fixture
15+
def async_user_groups_service(http_client):
16+
return AsyncUserGroupsService(http_client=http_client)
17+
18+
19+
@pytest.mark.parametrize(
20+
"method",
21+
["get", "create", "update", "delete"],
22+
)
23+
def test_mixins_present(user_groups_service, method):
24+
assert hasattr(user_groups_service, method)
25+
26+
27+
@pytest.mark.parametrize(
28+
"method",
29+
["get", "create", "update", "delete"],
30+
)
31+
def test_async_mixins_present(async_user_groups_service, method):
32+
assert hasattr(async_user_groups_service, method)

0 commit comments

Comments
 (0)