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
28 changes: 28 additions & 0 deletions mpt_api_client/resources/notifications/messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.models import Model


class Message(Model):
"""Notifications Message resource."""


class MessagesServiceConfig:
"""Notifications Messages service configuration."""

_endpoint = "/public/v1/notifications/messages"
_model_class = Message
_collection_key = "data"


class MessagesService(
Service[Message],
MessagesServiceConfig,
):
"""Notifications Messages service (no CRUD, no block/unblock)."""


class AsyncMessagesService(
AsyncService[Message],
MessagesServiceConfig,
):
"""Async Notifications Messages service (no CRUD, no block/unblock)."""
11 changes: 11 additions & 0 deletions mpt_api_client/resources/notifications/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
CategoriesService,
)
from mpt_api_client.resources.notifications.contacts import AsyncContactsService, ContactsService
from mpt_api_client.resources.notifications.messages import AsyncMessagesService, MessagesService


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

@property
def messages(self) -> MessagesService:
"""Messages service."""
return MessagesService(http_client=self.http_client)


class AsyncNotifications:
"""Notifications MPT API Module."""
Expand All @@ -38,3 +44,8 @@ def categories(self) -> AsyncCategoriesService:
def contacts(self) -> AsyncContactsService:
"""Async Contacts service."""
return AsyncContactsService(http_client=self.http_client)

@property
def messages(self) -> AsyncMessagesService:
"""Async Messages service."""
return AsyncMessagesService(http_client=self.http_client)
34 changes: 34 additions & 0 deletions tests/resources/notifications/test_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest

from mpt_api_client.resources.notifications.messages import (
AsyncMessagesService,
MessagesService,
)


@pytest.fixture
def messages_service(http_client):
return MessagesService(http_client=http_client)


@pytest.fixture
def async_messages_service(async_http_client):
return AsyncMessagesService(http_client=async_http_client)


def test_messages_service_instance(messages_service):
assert isinstance(messages_service, MessagesService)


def test_async_messages_service_instance(async_messages_service):
assert isinstance(async_messages_service, AsyncMessagesService)


@pytest.mark.parametrize("method", ["get", "iterate"])
def test_sync_messages_service_methods(messages_service, method):
assert hasattr(messages_service, method)


@pytest.mark.parametrize("method", ["get", "iterate"])
def test_async_messages_service_methods(async_messages_service, method):
assert hasattr(async_messages_service, method)
3 changes: 3 additions & 0 deletions tests/resources/notifications/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
CategoriesService,
)
from mpt_api_client.resources.notifications.contacts import AsyncContactsService, ContactsService
from mpt_api_client.resources.notifications.messages import AsyncMessagesService, MessagesService


def test_notifications_init(http_client):
Expand All @@ -27,6 +28,7 @@ def test_async_notifications_init(async_http_client):
[
("categories", CategoriesService),
("contacts", ContactsService),
("messages", MessagesService),
],
)
def test_notifications_properties(http_client, attr_name, expected):
Expand All @@ -42,6 +44,7 @@ def test_notifications_properties(http_client, attr_name, expected):
[
("categories", AsyncCategoriesService),
("contacts", AsyncContactsService),
("messages", AsyncMessagesService),
],
)
def test_async_notifications_properties(http_client, attr_name, expected):
Expand Down