Skip to content

Commit 4fc33c8

Browse files
committed
feat(tests): add E2E tests for notifications messages endpoint
1 parent 9976f92 commit 4fc33c8

File tree

6 files changed

+90
-6
lines changed

6 files changed

+90
-6
lines changed

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
}

tests/e2e/accounts/conftest.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ def currencies():
1818
return ["USD", "EUR"]
1919

2020

21-
@pytest.fixture
22-
def account_id(e2e_config):
23-
return e2e_config["accounts.account.id"]
24-
25-
2621
@pytest.fixture
2722
def seller_id(e2e_config):
2823
return e2e_config["accounts.seller.id"]

tests/e2e/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,8 @@ def logo_fd():
116116
@pytest.fixture
117117
def user_id(e2e_config):
118118
return e2e_config["accounts.user.id"]
119+
120+
121+
@pytest.fixture
122+
def account_id(e2e_config):
123+
return e2e_config["accounts.account.id"]
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 e2e_config.get("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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
if message_id is None:
10+
pytest.skip("Message ID not configured in e2e_config")
11+
service = mpt_client.notifications.messages
12+
13+
result = service.get(message_id)
14+
15+
assert result.id == message_id
16+
17+
18+
def test_list_messages(mpt_ops):
19+
service = mpt_ops.notifications.messages
20+
21+
result = service.fetch_page(limit=1)
22+
23+
assert len(result) > 0
24+
25+
26+
def test_not_found(mpt_client, invalid_message_id):
27+
service = mpt_client.notifications.messages
28+
29+
with pytest.raises(MPTAPIError):
30+
service.get(invalid_message_id)

0 commit comments

Comments
 (0)