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
40 changes: 40 additions & 0 deletions mpt_api_client/resources/accounts/account_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCreateMixin,
CreateMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.resources.accounts.mixins import (
AsyncInvitableMixin,
InvitableMixin,
)


class AccountUser(Model):
"""Account User Model."""


class AccountUsersServiceConfig:
"""Account Users Service Configuration."""

_endpoint = "/public/v1/accounts/account-users"
_model_class = AccountUser
_collection_key = "data"


class AccountUsersService(
CreateMixin[AccountUser],
InvitableMixin[AccountUser],
Service[AccountUser],
AccountUsersServiceConfig,
):
"""Account Users Service."""


class AsyncAccountUsersService(
AsyncCreateMixin[AccountUser],
AsyncService[AccountUser],
AsyncInvitableMixin[AccountUser],
AccountUsersServiceConfig,
):
"""Asynchronous Account Users Service."""
14 changes: 14 additions & 0 deletions mpt_api_client/resources/accounts/accounts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
from mpt_api_client.resources.accounts.account_users import (
AccountUsersService,
AsyncAccountUsersService,
)
from mpt_api_client.resources.accounts.api_tokens import ApiTokensService, AsyncApiTokensService
from mpt_api_client.resources.accounts.buyers import AsyncBuyersService, BuyersService
from mpt_api_client.resources.accounts.cloud_tenants import (
Expand Down Expand Up @@ -67,6 +71,11 @@ def buyers(self) -> BuyersService:
"""Buyers service."""
return BuyersService(http_client=self.http_client)

@property
def account_users(self) -> AccountUsersService:
"""Account Users service."""
return AccountUsersService(http_client=self.http_client)


class AsyncAccounts:
"""Async Accounts MPT API Module."""
Expand Down Expand Up @@ -118,3 +127,8 @@ def cloud_tenants(self) -> AsyncCloudTenantsService:
def buyers(self) -> AsyncBuyersService:
"""Buyers service."""
return AsyncBuyersService(http_client=self.http_client)

@property
def account_users(self) -> AsyncAccountUsersService:
"""Account Users service."""
return AsyncAccountUsersService(http_client=self.http_client)
32 changes: 32 additions & 0 deletions tests/resources/accounts/test_account_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest

from mpt_api_client.resources.accounts.account_users import (
AccountUsersService,
AsyncAccountUsersService,
)


@pytest.fixture
def account_users_service(http_client):
return AccountUsersService(http_client=http_client)


@pytest.fixture
def async_account_users_service(http_client):
return AsyncAccountUsersService(http_client=http_client)


@pytest.mark.parametrize(
"method",
["get", "create", "accept_invite", "resend_invite", "send_new_invite"],
)
def test_methods_present(account_users_service, method):
assert hasattr(account_users_service, method)


@pytest.mark.parametrize(
"method",
["get", "create", "accept_invite", "resend_invite", "send_new_invite"],
)
def test_async_methods_present(async_account_users_service, method):
assert hasattr(async_account_users_service, method)
6 changes: 6 additions & 0 deletions tests/resources/accounts/test_accounts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import pytest

from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
from mpt_api_client.resources.accounts.account_users import (
AccountUsersService,
AsyncAccountUsersService,
)
from mpt_api_client.resources.accounts.accounts import Accounts, AsyncAccounts
from mpt_api_client.resources.accounts.api_tokens import (
ApiTokensService,
Expand Down Expand Up @@ -43,6 +47,7 @@ def async_accounts(async_http_client):
("modules", ModulesService),
("cloud_tenants", CloudTenantsService),
("buyers", BuyersService),
("account_users", AccountUsersService),
],
)
def test_accounts_properties(accounts, property_name, expected_service_class):
Expand All @@ -65,6 +70,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
("modules", AsyncModulesService),
("cloud_tenants", AsyncCloudTenantsService),
("buyers", AsyncBuyersService),
("account_users", AsyncAccountUsersService),
],
)
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
Expand Down