From 37cb63e059d1aebe242e45e04e91c4f489e0dbbb Mon Sep 17 00:00:00 2001 From: Lukasz Lancucki Date: Fri, 28 Nov 2025 12:36:07 +0000 Subject: [PATCH 1/2] feat(tests): add sync and async E2E tests for notification categories --- tests/e2e/notifications/__init__.py | 0 .../e2e/notifications/categories/__init__.py | 0 .../e2e/notifications/categories/conftest.py | 15 +++ .../categories/test_async_categories.py | 107 ++++++++++++++++++ .../categories/test_sync_categories.py | 105 +++++++++++++++++ 5 files changed, 227 insertions(+) create mode 100644 tests/e2e/notifications/__init__.py create mode 100644 tests/e2e/notifications/categories/__init__.py create mode 100644 tests/e2e/notifications/categories/conftest.py create mode 100644 tests/e2e/notifications/categories/test_async_categories.py create mode 100644 tests/e2e/notifications/categories/test_sync_categories.py diff --git a/tests/e2e/notifications/__init__.py b/tests/e2e/notifications/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/e2e/notifications/categories/__init__.py b/tests/e2e/notifications/categories/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/e2e/notifications/categories/conftest.py b/tests/e2e/notifications/categories/conftest.py new file mode 100644 index 00000000..02bc656a --- /dev/null +++ b/tests/e2e/notifications/categories/conftest.py @@ -0,0 +1,15 @@ +import pytest + + +@pytest.fixture +def category_data(short_uuid): + return { + "name": f"e2e-category-{short_uuid}", + "description": "E2E test category - please delete", + "externalId": f"e2e-cat-{short_uuid}", + } + + +@pytest.fixture +def invalid_category_id(): + return "NCT-000-000-000" diff --git a/tests/e2e/notifications/categories/test_async_categories.py b/tests/e2e/notifications/categories/test_async_categories.py new file mode 100644 index 00000000..92d947df --- /dev/null +++ b/tests/e2e/notifications/categories/test_async_categories.py @@ -0,0 +1,107 @@ +import pytest + +from mpt_api_client.exceptions import MPTAPIError +from mpt_api_client.rql.query_builder import RQLQuery + +pytestmark = [pytest.mark.flaky] + + +@pytest.fixture +async def async_created_category(async_mpt_ops, category_data): + service = async_mpt_ops.notifications.categories + category = await service.create(category_data) + yield category + try: + await service.delete(category.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete category {category.id}: {error.title}") # noqa: WPS421 + + +def test_create_category(async_created_category, category_data): # noqa: AAA01 + assert async_created_category.name == category_data["name"] + assert async_created_category.description == category_data["description"] + + +async def test_get_category(async_mpt_vendor, async_created_category): + service = async_mpt_vendor.notifications.categories + + result = await service.get(async_created_category.id) + + assert result.id == async_created_category.id + assert result.name == async_created_category.name + + +async def test_update_category(async_mpt_ops, async_created_category): + service = async_mpt_ops.notifications.categories + update_data = { + "name": "e2e-async-updated-category", + "description": "Async updated description", + } + + result = await service.update(async_created_category.id, update_data) + + assert result.name == "e2e-async-updated-category" + assert result.description == "Async updated description" + + +async def test_list_categories(async_mpt_vendor, async_created_category): + service = async_mpt_vendor.notifications.categories + + result = [category async for category in service.iterate()] + + assert any(category.id == async_created_category.id for category in result) + + +async def test_filter_categories(async_mpt_vendor, async_created_category): + service = async_mpt_vendor.notifications.categories + + result = [ + category + async for category in service.filter(RQLQuery(id=async_created_category.id)).iterate() + ] + + assert len(result) == 1 + assert result[0].id == async_created_category.id + + +async def test_publish_category(async_mpt_ops, async_created_category): + service = async_mpt_ops.notifications.categories + unpublish_note_data = {"note": "Unpublishing category for async testing"} + await service.unpublish(async_created_category.id, unpublish_note_data) + note_data = {"note": "Publishing category for async testing"} + + result = await service.publish(async_created_category.id, note_data) + + assert result.id == async_created_category.id + + +async def test_unpublish_category(async_mpt_ops, async_created_category): + service = async_mpt_ops.notifications.categories + unpublish_note_data = {"note": "Unpublishing category for async testing"} + + result = await service.unpublish(async_created_category.id, unpublish_note_data) + + assert result.id == async_created_category.id + + +async def test_category_not_found(async_mpt_vendor, invalid_category_id): + service = async_mpt_vendor.notifications.categories + + with pytest.raises(MPTAPIError): + await service.get(invalid_category_id) + + +async def test_delete_category(async_mpt_ops, async_created_category): + service = async_mpt_ops.notifications.categories + + await service.delete(async_created_category.id) + + with pytest.raises(MPTAPIError): + await service.get(async_created_category.id) + + +async def test_delete_category_not_found(async_mpt_ops, invalid_category_id): + service = async_mpt_ops.notifications.categories + + with pytest.raises(MPTAPIError): + await service.delete(invalid_category_id) diff --git a/tests/e2e/notifications/categories/test_sync_categories.py b/tests/e2e/notifications/categories/test_sync_categories.py new file mode 100644 index 00000000..74c017b5 --- /dev/null +++ b/tests/e2e/notifications/categories/test_sync_categories.py @@ -0,0 +1,105 @@ +import pytest + +from mpt_api_client.exceptions import MPTAPIError +from mpt_api_client.rql.query_builder import RQLQuery + +pytestmark = [pytest.mark.flaky] + + +@pytest.fixture +def created_category(mpt_ops, category_data): + service = mpt_ops.notifications.categories + category = service.create(category_data) + yield category + try: + service.delete(category.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete category {category.id}: {error.title}") # noqa: WPS421 + + +def test_create_category(created_category, category_data): + assert created_category.name == category_data["name"] # act + + assert created_category.description == category_data["description"] + + +def test_get_category(mpt_client, created_category): + service = mpt_client.notifications.categories + + result = service.get(created_category.id) + + assert result.id == created_category.id + assert result.name == created_category.name + + +def test_update_category(mpt_ops, created_category): + service = mpt_ops.notifications.categories + update_data = { + "name": "e2e-updated-category", + "description": "Updated description", + } + + result = service.update(created_category.id, update_data) + + assert result.name == "e2e-updated-category" + assert result.description == "Updated description" + + +def test_list_categories(mpt_client, created_category): + service = mpt_client.notifications.categories + + result = list(service.iterate()) + + assert any(category.id == created_category.id for category in result) + + +def test_filter_categories(mpt_client, created_category): + service = mpt_client.notifications.categories + + result = list(service.filter(RQLQuery(id=created_category.id)).iterate()) + + assert len(result) == 1 + assert result[0].id == created_category.id + + +def test_publish_category(mpt_ops, created_category): + service = mpt_ops.notifications.categories + unpublish_note_data = {"note": "Unpublishing category for testing"} + service.unpublish(created_category.id, unpublish_note_data) + note_data = {"note": "Publishing category for testing"} + + result = service.publish(created_category.id, note_data) + + assert result.id == created_category.id + + +def test_unpublish_category(mpt_ops, created_category): + service = mpt_ops.notifications.categories + unpublish_note_data = {"note": "Unpublishing category for testing"} + + result = service.unpublish(created_category.id, unpublish_note_data) + + assert result.id == created_category.id + + +def test_category_not_found(mpt_client, invalid_category_id): + service = mpt_client.notifications.categories + + with pytest.raises(MPTAPIError): + service.get(invalid_category_id) + + +def test_delete_category(mpt_ops, created_category): + service = mpt_ops.notifications.categories + + service.delete(created_category.id) # act + + with pytest.raises(MPTAPIError): + service.get(created_category.id) + + +def test_delete_category_not_found(mpt_ops, invalid_category_id): + service = mpt_ops.notifications.categories + + with pytest.raises(MPTAPIError): + service.delete(invalid_category_id) From 6769a914be59e1585c74f8aeb4d34eacac3cc564 Mon Sep 17 00:00:00 2001 From: Lukasz Lancucki Date: Mon, 1 Dec 2025 14:13:15 +0000 Subject: [PATCH 2/2] test: skip slow notification category tests due to performance issue MPT-13785 --- .../notifications/categories/test_async_categories.py | 10 +++++++++- .../notifications/categories/test_sync_categories.py | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/e2e/notifications/categories/test_async_categories.py b/tests/e2e/notifications/categories/test_async_categories.py index 92d947df..fa46d728 100644 --- a/tests/e2e/notifications/categories/test_async_categories.py +++ b/tests/e2e/notifications/categories/test_async_categories.py @@ -17,11 +17,13 @@ async def async_created_category(async_mpt_ops, category_data): print(f"TEARDOWN - Unable to delete category {category.id}: {error.title}") # noqa: WPS421 -def test_create_category(async_created_category, category_data): # noqa: AAA01 +@pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") # noqa: AAA01 +def test_create_category(async_created_category, category_data): assert async_created_category.name == category_data["name"] assert async_created_category.description == category_data["description"] +@pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") async def test_get_category(async_mpt_vendor, async_created_category): service = async_mpt_vendor.notifications.categories @@ -31,6 +33,7 @@ async def test_get_category(async_mpt_vendor, async_created_category): assert result.name == async_created_category.name +@pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") async def test_update_category(async_mpt_ops, async_created_category): service = async_mpt_ops.notifications.categories update_data = { @@ -44,6 +47,7 @@ async def test_update_category(async_mpt_ops, async_created_category): assert result.description == "Async updated description" +@pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") async def test_list_categories(async_mpt_vendor, async_created_category): service = async_mpt_vendor.notifications.categories @@ -52,6 +56,7 @@ async def test_list_categories(async_mpt_vendor, async_created_category): assert any(category.id == async_created_category.id for category in result) +@pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") async def test_filter_categories(async_mpt_vendor, async_created_category): service = async_mpt_vendor.notifications.categories @@ -64,6 +69,7 @@ async def test_filter_categories(async_mpt_vendor, async_created_category): assert result[0].id == async_created_category.id +@pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") async def test_publish_category(async_mpt_ops, async_created_category): service = async_mpt_ops.notifications.categories unpublish_note_data = {"note": "Unpublishing category for async testing"} @@ -75,6 +81,7 @@ async def test_publish_category(async_mpt_ops, async_created_category): assert result.id == async_created_category.id +@pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") async def test_unpublish_category(async_mpt_ops, async_created_category): service = async_mpt_ops.notifications.categories unpublish_note_data = {"note": "Unpublishing category for async testing"} @@ -91,6 +98,7 @@ async def test_category_not_found(async_mpt_vendor, invalid_category_id): await service.get(invalid_category_id) +@pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") async def test_delete_category(async_mpt_ops, async_created_category): service = async_mpt_ops.notifications.categories diff --git a/tests/e2e/notifications/categories/test_sync_categories.py b/tests/e2e/notifications/categories/test_sync_categories.py index 74c017b5..37370c91 100644 --- a/tests/e2e/notifications/categories/test_sync_categories.py +++ b/tests/e2e/notifications/categories/test_sync_categories.py @@ -17,12 +17,14 @@ def created_category(mpt_ops, category_data): print(f"TEARDOWN - Unable to delete category {category.id}: {error.title}") # noqa: WPS421 +@pytest.mark.skip(reason="created_category kills performance due to MPT-13785") def test_create_category(created_category, category_data): assert created_category.name == category_data["name"] # act assert created_category.description == category_data["description"] +@pytest.mark.skip(reason="created_category kills performance due to MPT-13785") def test_get_category(mpt_client, created_category): service = mpt_client.notifications.categories @@ -32,6 +34,7 @@ def test_get_category(mpt_client, created_category): assert result.name == created_category.name +@pytest.mark.skip(reason="created_category kills performance due to MPT-13785") def test_update_category(mpt_ops, created_category): service = mpt_ops.notifications.categories update_data = { @@ -45,6 +48,7 @@ def test_update_category(mpt_ops, created_category): assert result.description == "Updated description" +@pytest.mark.skip(reason="created_category kills performance due to MPT-13785") def test_list_categories(mpt_client, created_category): service = mpt_client.notifications.categories @@ -53,6 +57,7 @@ def test_list_categories(mpt_client, created_category): assert any(category.id == created_category.id for category in result) +@pytest.mark.skip(reason="created_category kills performance due to MPT-13785") def test_filter_categories(mpt_client, created_category): service = mpt_client.notifications.categories @@ -62,6 +67,7 @@ def test_filter_categories(mpt_client, created_category): assert result[0].id == created_category.id +@pytest.mark.skip(reason="created_category kills performance due to MPT-13785") def test_publish_category(mpt_ops, created_category): service = mpt_ops.notifications.categories unpublish_note_data = {"note": "Unpublishing category for testing"} @@ -73,6 +79,7 @@ def test_publish_category(mpt_ops, created_category): assert result.id == created_category.id +@pytest.mark.skip(reason="created_category kills performance due to MPT-13785") def test_unpublish_category(mpt_ops, created_category): service = mpt_ops.notifications.categories unpublish_note_data = {"note": "Unpublishing category for testing"} @@ -89,6 +96,7 @@ def test_category_not_found(mpt_client, invalid_category_id): service.get(invalid_category_id) +@pytest.mark.skip(reason="created_category kills performance due to MPT-13785") def test_delete_category(mpt_ops, created_category): service = mpt_ops.notifications.categories