diff --git a/mpt_api_client/resources/notifications/accounts.py b/mpt_api_client/resources/notifications/accounts.py index 264c9b4..c2e8e72 100644 --- a/mpt_api_client/resources/notifications/accounts.py +++ b/mpt_api_client/resources/notifications/accounts.py @@ -1,5 +1,6 @@ from mpt_api_client.exceptions import MPTError from mpt_api_client.http import AsyncService, Service +from mpt_api_client.http.mixins import AsyncCollectionMixin, CollectionMixin from mpt_api_client.models import Model @@ -7,21 +8,27 @@ class MethodNotAllowedError(MPTError): """Method not allowed error.""" -class Contact(Model): - """Account resource.""" +class NotificationContact(Model): + """Notification Contact resource.""" class AccountsServiceConfig: """Accounts service config.""" - _endpoint = "/public/v1/commerce/accounts/{account_id}/categories/{category_id}/contacts" - _model_class = Contact + _endpoint = "/public/v1/notifications/accounts/{account_id}/categories/{category_id}/contacts" + _model_class = NotificationContact _collection_key = "data" -class AccountsService(Service[Contact], AccountsServiceConfig): +class AccountsService( + CollectionMixin[NotificationContact], Service[NotificationContact], AccountsServiceConfig +): """Accounts service.""" -class AsyncAccountsService(AsyncService[Contact], AccountsServiceConfig): +class AsyncAccountsService( + AsyncCollectionMixin[NotificationContact], + AsyncService[NotificationContact], + AccountsServiceConfig, +): """Async Accounts service.""" diff --git a/tests/e2e/notifications/accounts/test_async_accounts.py b/tests/e2e/notifications/accounts/test_async_accounts.py new file mode 100644 index 0000000..796e99a --- /dev/null +++ b/tests/e2e/notifications/accounts/test_async_accounts.py @@ -0,0 +1,8 @@ +async def test_async_accounts(async_mpt_ops, account_id, category_id): + iterator = async_mpt_ops.notifications.accounts( + account_id=account_id, category_id=category_id + ).iterate() + + result = [contact async for contact in iterator] + + assert isinstance(result, list) diff --git a/tests/e2e/notifications/accounts/test_sync_accounts.py b/tests/e2e/notifications/accounts/test_sync_accounts.py new file mode 100644 index 0000000..ee39214 --- /dev/null +++ b/tests/e2e/notifications/accounts/test_sync_accounts.py @@ -0,0 +1,8 @@ +def test_accounts(mpt_ops, account_id, category_id): + iterator = mpt_ops.notifications.accounts( + account_id=account_id, category_id=category_id + ).iterate() + + result = list(iterator) + + assert isinstance(result, list) diff --git a/tests/unit/resources/notifications/test_accounts.py b/tests/unit/resources/notifications/test_accounts.py index f71238c..9066b8e 100644 --- a/tests/unit/resources/notifications/test_accounts.py +++ b/tests/unit/resources/notifications/test_accounts.py @@ -14,3 +14,17 @@ def accounts_service(http_client): @pytest.fixture def async_accounts_service(async_http_client): return AsyncAccountsService(http_client=async_http_client) + + +@pytest.mark.parametrize("method", ["iterate"]) +def test_sync_accounts_service_methods(accounts_service, method): + result = hasattr(accounts_service, method) + + assert result is True + + +@pytest.mark.parametrize("method", ["iterate"]) +def test_async_accounts_service_methods(async_accounts_service, method): + result = hasattr(async_accounts_service, method) + + assert result is True