-
Notifications
You must be signed in to change notification settings - Fork 0
MPT-14932 add sync and async E2E tests for notification categories #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" |
115 changes: 115 additions & 0 deletions
115
tests/e2e/notifications/categories/test_async_categories.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| 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 | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") # noqa: AAA01 | ||
jentyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
|
|
||
| result = await service.get(async_created_category.id) | ||
|
|
||
| assert result.id == async_created_category.id | ||
| 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 = { | ||
| "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" | ||
|
|
||
|
|
||
| @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 | ||
|
|
||
| result = [category async for category in service.iterate()] | ||
|
|
||
| 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 | ||
|
|
||
| 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 | ||
|
|
||
|
|
||
| @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"} | ||
| 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 | ||
|
|
||
|
|
||
| @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"} | ||
|
|
||
| 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) | ||
|
|
||
|
|
||
| @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 | ||
|
|
||
| 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) | ||
113 changes: 113 additions & 0 deletions
113
tests/e2e/notifications/categories/test_sync_categories.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| 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 | ||
jentyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| @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 | ||
|
|
||
| result = service.get(created_category.id) | ||
|
|
||
| assert result.id == created_category.id | ||
| 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 = { | ||
| "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" | ||
|
|
||
|
|
||
| @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 | ||
|
|
||
| result = list(service.iterate()) | ||
|
|
||
| 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 | ||
|
|
||
| result = list(service.filter(RQLQuery(id=created_category.id)).iterate()) | ||
|
|
||
| assert len(result) == 1 | ||
| 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"} | ||
| 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 | ||
|
|
||
|
|
||
| @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"} | ||
|
|
||
| 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) | ||
|
|
||
|
|
||
| @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 | ||
|
|
||
| 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) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.