Skip to content

Commit 7fb95f5

Browse files
authored
MPT-14076 Add notifications messages (#82)
2 parents b7f39d8 + 7342d94 commit 7fb95f5

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.models import Model
3+
4+
5+
class Message(Model):
6+
"""Notifications Message resource."""
7+
8+
9+
class MessagesServiceConfig:
10+
"""Notifications Messages service configuration."""
11+
12+
_endpoint = "/public/v1/notifications/messages"
13+
_model_class = Message
14+
_collection_key = "data"
15+
16+
17+
class MessagesService(
18+
Service[Message],
19+
MessagesServiceConfig,
20+
):
21+
"""Notifications Messages service (no CRUD, no block/unblock)."""
22+
23+
24+
class AsyncMessagesService(
25+
AsyncService[Message],
26+
MessagesServiceConfig,
27+
):
28+
"""Async Notifications Messages service (no CRUD, no block/unblock)."""

mpt_api_client/resources/notifications/notifications.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
CategoriesService,
55
)
66
from mpt_api_client.resources.notifications.contacts import AsyncContactsService, ContactsService
7+
from mpt_api_client.resources.notifications.messages import AsyncMessagesService, MessagesService
78

89

910
class Notifications:
@@ -22,6 +23,11 @@ def contacts(self) -> ContactsService:
2223
"""Contacts service."""
2324
return ContactsService(http_client=self.http_client)
2425

26+
@property
27+
def messages(self) -> MessagesService:
28+
"""Messages service."""
29+
return MessagesService(http_client=self.http_client)
30+
2531

2632
class AsyncNotifications:
2733
"""Notifications MPT API Module."""
@@ -38,3 +44,8 @@ def categories(self) -> AsyncCategoriesService:
3844
def contacts(self) -> AsyncContactsService:
3945
"""Async Contacts service."""
4046
return AsyncContactsService(http_client=self.http_client)
47+
48+
@property
49+
def messages(self) -> AsyncMessagesService:
50+
"""Async Messages service."""
51+
return AsyncMessagesService(http_client=self.http_client)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.notifications.messages import (
4+
AsyncMessagesService,
5+
MessagesService,
6+
)
7+
8+
9+
@pytest.fixture
10+
def messages_service(http_client):
11+
return MessagesService(http_client=http_client)
12+
13+
14+
@pytest.fixture
15+
def async_messages_service(async_http_client):
16+
return AsyncMessagesService(http_client=async_http_client)
17+
18+
19+
def test_messages_service_instance(messages_service):
20+
assert isinstance(messages_service, MessagesService)
21+
22+
23+
def test_async_messages_service_instance(async_messages_service):
24+
assert isinstance(async_messages_service, AsyncMessagesService)
25+
26+
27+
@pytest.mark.parametrize("method", ["get", "iterate"])
28+
def test_sync_messages_service_methods(messages_service, method):
29+
assert hasattr(messages_service, method)
30+
31+
32+
@pytest.mark.parametrize("method", ["get", "iterate"])
33+
def test_async_messages_service_methods(async_messages_service, method):
34+
assert hasattr(async_messages_service, method)

tests/resources/notifications/test_notifications.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
CategoriesService,
77
)
88
from mpt_api_client.resources.notifications.contacts import AsyncContactsService, ContactsService
9+
from mpt_api_client.resources.notifications.messages import AsyncMessagesService, MessagesService
910

1011

1112
def test_notifications_init(http_client):
@@ -27,6 +28,7 @@ def test_async_notifications_init(async_http_client):
2728
[
2829
("categories", CategoriesService),
2930
("contacts", ContactsService),
31+
("messages", MessagesService),
3032
],
3133
)
3234
def test_notifications_properties(http_client, attr_name, expected):
@@ -42,6 +44,7 @@ def test_notifications_properties(http_client, attr_name, expected):
4244
[
4345
("categories", AsyncCategoriesService),
4446
("contacts", AsyncContactsService),
47+
("messages", AsyncMessagesService),
4548
],
4649
)
4750
def test_async_notifications_properties(http_client, attr_name, expected):

0 commit comments

Comments
 (0)