-
Notifications
You must be signed in to change notification settings - Fork 0
MPT-14934 add E2E tests for notifications batches #169
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def batch_service(mpt_ops): | ||
| return mpt_ops.notifications.batches | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def async_batch_service(async_mpt_ops): | ||
| return async_mpt_ops.notifications.batches | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def batch_id(e2e_config): | ||
| return e2e_config["notifications.batch.id"] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def batch_data(category_id, short_uuid): | ||
| return { | ||
| "category": {"id": category_id}, | ||
| "subject": f"E2E - please delete - {short_uuid}", | ||
| "body": "Hello world", | ||
| "contacts": [{"email": f"{short_uuid}@example.com"}], | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client.rql.query_builder import RQLQuery | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="Batches can not be deleted") | ||
| async def test_create_batch(async_batch_service, batch_data): | ||
| result = await async_batch_service.create(batch_data) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| async def test_get_batch(async_batch_service, batch_id): | ||
| result = await async_batch_service.get(batch_id) | ||
|
|
||
| assert result.id == batch_id | ||
|
|
||
|
|
||
| async def test_iterate_and_filter(async_batch_service, batch_id): | ||
| batches = [batch async for batch in async_batch_service.filter(RQLQuery(id=batch_id)).iterate()] | ||
|
|
||
| assert len(batches) == 1 | ||
| assert batches[0].id == batch_id | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="Batches can not be deleted") | ||
| async def test_create_batch_with_file(async_batch_service, batch_data, logo_fd): | ||
| result = await async_batch_service.create(batch_data, file=logo_fd) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="Batches attachments not implemented") | ||
| async def test_download_attachment(): | ||
| # TODO - Implement get and download E2E tests for attachments | ||
| raise NotImplementedError |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client import RQLQuery | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="Batches can not be deleted") | ||
| def test_create_batch(batch_service, batch_data): | ||
| result = batch_service.create(batch_data) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| def test_get_batch(batch_service, batch_id): | ||
| result = batch_service.get(batch_id) | ||
|
|
||
| assert result.id == batch_id | ||
|
|
||
|
|
||
| def test_iterate_and_filter(batch_service, batch_id): | ||
| result = list(batch_service.filter(RQLQuery(id=batch_id)).iterate()) | ||
|
|
||
| assert len(result) == 1 | ||
| assert result[0].id == batch_id | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="Batches can not be deleted") | ||
| def test_create_batch_with_file(batch_service, batch_data, logo_fd): | ||
| result = batch_service.create(batch_data, file=logo_fd) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="Batches attachments not implemented") # noqa: AAA01 | ||
| def test_download_attachment(): | ||
| # TODO - Implement get and download E2E tests for attachment | ||
| raise NotImplementedError | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,23 +17,19 @@ async def async_created_category(async_mpt_ops, category_data): | |||||||||||||
| 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 | ||||||||||||||
| def test_create_category(async_created_category, category_data): | ||||||||||||||
| 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"] | ||||||||||||||
|
Comment on lines
+20
to
22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused The 🔎 Apply this diff to remove the unused directive:-def test_create_category(async_created_category, category_data): # 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"]📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.14.8)20-20: Unused Remove unused (RUF100) 🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| @pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") | ||||||||||||||
| async def test_get_category(async_mpt_vendor, async_created_category): | ||||||||||||||
| async def test_get_category(async_mpt_vendor, category_id): | ||||||||||||||
| service = async_mpt_vendor.notifications.categories | ||||||||||||||
|
|
||||||||||||||
| result = await service.get(async_created_category.id) | ||||||||||||||
| result = await service.get(category_id) | ||||||||||||||
|
|
||||||||||||||
| assert result.id == async_created_category.id | ||||||||||||||
| assert result.name == async_created_category.name | ||||||||||||||
| assert result.id == category_id | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| @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 = { | ||||||||||||||
|
|
@@ -47,26 +43,13 @@ 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): | ||||||||||||||
| async def test_filter_categories(async_mpt_vendor, category_id): | ||||||||||||||
| 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() | ||||||||||||||
| ] | ||||||||||||||
| result = [category async for category in service.filter(RQLQuery(id=category_id)).iterate()] | ||||||||||||||
|
|
||||||||||||||
| assert len(result) == 1 | ||||||||||||||
| assert result[0].id == async_created_category.id | ||||||||||||||
| assert result[0].id == category_id | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| @pytest.mark.skip(reason="async_created_category kills performance due to MPT-13785") | ||||||||||||||
|
|
@@ -98,15 +81,11 @@ 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 | ||||||||||||||
|
|
||||||||||||||
| 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 | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def category_id(e2e_config): | ||
| return e2e_config["notifications.category.id"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused
noqadirective.The
# noqa: AAA01directive references an unknown linting code and should be removed.🔎 Apply this diff to remove the unused directive:
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.14.8)
33-33: Unused
noqadirective (unknown:AAA01)Remove unused
noqadirective(RUF100)
🤖 Prompt for AI Agents