Skip to content

Commit f8b709b

Browse files
authored
[MPT-14089] Added Accounts account-users endpoints (#86)
Added Accounts account-users endpoints https://softwareone.atlassian.net/browse/MPT-14089
2 parents b483ddf + e778643 commit f8b709b

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.http.mixins import (
3+
AsyncCreateMixin,
4+
CreateMixin,
5+
)
6+
from mpt_api_client.models import Model
7+
from mpt_api_client.resources.accounts.mixins import (
8+
AsyncInvitableMixin,
9+
InvitableMixin,
10+
)
11+
12+
13+
class AccountUser(Model):
14+
"""Account User Model."""
15+
16+
17+
class AccountUsersServiceConfig:
18+
"""Account Users Service Configuration."""
19+
20+
_endpoint = "/public/v1/accounts/account-users"
21+
_model_class = AccountUser
22+
_collection_key = "data"
23+
24+
25+
class AccountUsersService(
26+
CreateMixin[AccountUser],
27+
InvitableMixin[AccountUser],
28+
Service[AccountUser],
29+
AccountUsersServiceConfig,
30+
):
31+
"""Account Users Service."""
32+
33+
34+
class AsyncAccountUsersService(
35+
AsyncCreateMixin[AccountUser],
36+
AsyncService[AccountUser],
37+
AsyncInvitableMixin[AccountUser],
38+
AccountUsersServiceConfig,
39+
):
40+
"""Asynchronous Account Users Service."""

mpt_api_client/resources/accounts/accounts.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
22
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
3+
from mpt_api_client.resources.accounts.account_users import (
4+
AccountUsersService,
5+
AsyncAccountUsersService,
6+
)
37
from mpt_api_client.resources.accounts.api_tokens import ApiTokensService, AsyncApiTokensService
48
from mpt_api_client.resources.accounts.buyers import AsyncBuyersService, BuyersService
59
from mpt_api_client.resources.accounts.cloud_tenants import (
@@ -67,6 +71,11 @@ def buyers(self) -> BuyersService:
6771
"""Buyers service."""
6872
return BuyersService(http_client=self.http_client)
6973

74+
@property
75+
def account_users(self) -> AccountUsersService:
76+
"""Account Users service."""
77+
return AccountUsersService(http_client=self.http_client)
78+
7079

7180
class AsyncAccounts:
7281
"""Async Accounts MPT API Module."""
@@ -118,3 +127,8 @@ def cloud_tenants(self) -> AsyncCloudTenantsService:
118127
def buyers(self) -> AsyncBuyersService:
119128
"""Buyers service."""
120129
return AsyncBuyersService(http_client=self.http_client)
130+
131+
@property
132+
def account_users(self) -> AsyncAccountUsersService:
133+
"""Account Users service."""
134+
return AsyncAccountUsersService(http_client=self.http_client)
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.account_users import (
4+
AccountUsersService,
5+
AsyncAccountUsersService,
6+
)
7+
8+
9+
@pytest.fixture
10+
def account_users_service(http_client):
11+
return AccountUsersService(http_client=http_client)
12+
13+
14+
@pytest.fixture
15+
def async_account_users_service(http_client):
16+
return AsyncAccountUsersService(http_client=http_client)
17+
18+
19+
@pytest.mark.parametrize(
20+
"method",
21+
["get", "create", "accept_invite", "resend_invite", "send_new_invite"],
22+
)
23+
def test_methods_present(account_users_service, method):
24+
assert hasattr(account_users_service, method)
25+
26+
27+
@pytest.mark.parametrize(
28+
"method",
29+
["get", "create", "accept_invite", "resend_invite", "send_new_invite"],
30+
)
31+
def test_async_methods_present(async_account_users_service, method):
32+
assert hasattr(async_account_users_service, method)

tests/resources/accounts/test_accounts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import pytest
22

33
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
4+
from mpt_api_client.resources.accounts.account_users import (
5+
AccountUsersService,
6+
AsyncAccountUsersService,
7+
)
48
from mpt_api_client.resources.accounts.accounts import Accounts, AsyncAccounts
59
from mpt_api_client.resources.accounts.api_tokens import (
610
ApiTokensService,
@@ -43,6 +47,7 @@ def async_accounts(async_http_client):
4347
("modules", ModulesService),
4448
("cloud_tenants", CloudTenantsService),
4549
("buyers", BuyersService),
50+
("account_users", AccountUsersService),
4651
],
4752
)
4853
def test_accounts_properties(accounts, property_name, expected_service_class):
@@ -65,6 +70,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
6570
("modules", AsyncModulesService),
6671
("cloud_tenants", AsyncCloudTenantsService),
6772
("buyers", AsyncBuyersService),
73+
("account_users", AsyncAccountUsersService),
6874
],
6975
)
7076
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):

0 commit comments

Comments
 (0)