Skip to content

Commit 33d5413

Browse files
committed
feat(tests): add E2E tests for notifications messages endpoint
1 parent 1003ee5 commit 33d5413

4 files changed

Lines changed: 83 additions & 1 deletion

File tree

e2e_config.test.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
"catalog.product.template.id": "TPL-7255-3950-0001",
2121
"catalog.product.terms.id": "TCS-7255-3950-0001",
2222
"catalog.product.terms.variant.id": "TCV-7255-3950-0001-0001",
23-
"catalog.unit.id": "UNT-1229"
23+
"catalog.unit.id": "UNT-1229",
24+
"notifications.message.id": "MSG-0000-6215-1019-0139"
2425
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def message_data(short_uuid, account_id):
6+
return {
7+
"title": "e2e - please delete",
8+
"content": "This is an e2e test message - please delete",
9+
"category": "general",
10+
"priority": "normal",
11+
"account": {
12+
"id": account_id,
13+
},
14+
"externalIds": {"test": f"e2e-delete-{short_uuid}"},
15+
}
16+
17+
18+
@pytest.fixture
19+
def message_id(e2e_config):
20+
return e2e_config.get("notifications.message.id")
21+
22+
23+
@pytest.fixture
24+
def invalid_message_id(e2e_config):
25+
return "MSG-000-000-000-000"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pytest
2+
3+
from mpt_api_client.exceptions import MPTAPIError
4+
5+
pytestmark = [pytest.mark.flaky]
6+
7+
8+
async def test_get_message(async_mpt_client, message_id):
9+
service = async_mpt_client.notifications.messages
10+
11+
result = await service.get(message_id)
12+
13+
assert result.id == message_id
14+
15+
16+
async def test_list_messages(async_mpt_ops):
17+
service = async_mpt_ops.notifications.messages
18+
19+
result = await service.fetch_page(limit=1)
20+
21+
assert len(result) > 0
22+
23+
24+
async def test_not_found(async_mpt_client, invalid_message_id):
25+
service = async_mpt_client.notifications.messages
26+
27+
with pytest.raises(MPTAPIError):
28+
await service.get(invalid_message_id)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pytest
2+
3+
from mpt_api_client.exceptions import MPTAPIError
4+
5+
pytestmark = [pytest.mark.flaky]
6+
7+
8+
def test_get_message(mpt_client, message_id):
9+
service = mpt_client.notifications.messages
10+
11+
result = service.get(message_id)
12+
13+
assert result.id == message_id
14+
15+
16+
def test_list_messages(mpt_ops):
17+
service = mpt_ops.notifications.messages
18+
19+
result = service.fetch_page(limit=1)
20+
21+
assert len(result) > 0
22+
23+
24+
def test_not_found(mpt_client, invalid_message_id):
25+
service = mpt_client.notifications.messages
26+
27+
with pytest.raises(MPTAPIError):
28+
service.get(invalid_message_id)

0 commit comments

Comments
 (0)