Skip to content

Commit f47c482

Browse files
authored
MPT-14937 E2E for notifications accounts categories contacts (#170)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Accounts notifications now support iteration over contacts in both synchronous and asynchronous flows. * Notifications API endpoint for accounts updated to the notifications path. * **Tests** * Added end-to-end and unit tests validating sync and async iteration behavior. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 5b5d899 + 649c11b commit f47c482

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
from mpt_api_client.exceptions import MPTError
22
from mpt_api_client.http import AsyncService, Service
3+
from mpt_api_client.http.mixins import AsyncCollectionMixin, CollectionMixin
34
from mpt_api_client.models import Model
45

56

67
class MethodNotAllowedError(MPTError):
78
"""Method not allowed error."""
89

910

10-
class Contact(Model):
11-
"""Account resource."""
11+
class NotificationContact(Model):
12+
"""Notification Contact resource."""
1213

1314

1415
class AccountsServiceConfig:
1516
"""Accounts service config."""
1617

17-
_endpoint = "/public/v1/commerce/accounts/{account_id}/categories/{category_id}/contacts"
18-
_model_class = Contact
18+
_endpoint = "/public/v1/notifications/accounts/{account_id}/categories/{category_id}/contacts"
19+
_model_class = NotificationContact
1920
_collection_key = "data"
2021

2122

22-
class AccountsService(Service[Contact], AccountsServiceConfig):
23+
class AccountsService(
24+
CollectionMixin[NotificationContact], Service[NotificationContact], AccountsServiceConfig
25+
):
2326
"""Accounts service."""
2427

2528

26-
class AsyncAccountsService(AsyncService[Contact], AccountsServiceConfig):
29+
class AsyncAccountsService(
30+
AsyncCollectionMixin[NotificationContact],
31+
AsyncService[NotificationContact],
32+
AccountsServiceConfig,
33+
):
2734
"""Async Accounts service."""
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
async def test_async_accounts(async_mpt_ops, account_id, category_id):
2+
iterator = async_mpt_ops.notifications.accounts(
3+
account_id=account_id, category_id=category_id
4+
).iterate()
5+
6+
result = [contact async for contact in iterator]
7+
8+
assert isinstance(result, list)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def test_accounts(mpt_ops, account_id, category_id):
2+
iterator = mpt_ops.notifications.accounts(
3+
account_id=account_id, category_id=category_id
4+
).iterate()
5+
6+
result = list(iterator)
7+
8+
assert isinstance(result, list)

tests/unit/resources/notifications/test_accounts.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,17 @@ def accounts_service(http_client):
1414
@pytest.fixture
1515
def async_accounts_service(async_http_client):
1616
return AsyncAccountsService(http_client=async_http_client)
17+
18+
19+
@pytest.mark.parametrize("method", ["iterate"])
20+
def test_sync_accounts_service_methods(accounts_service, method):
21+
result = hasattr(accounts_service, method)
22+
23+
assert result is True
24+
25+
26+
@pytest.mark.parametrize("method", ["iterate"])
27+
def test_async_accounts_service_methods(async_accounts_service, method):
28+
result = hasattr(async_accounts_service, method)
29+
30+
assert result is True

0 commit comments

Comments
 (0)