-
Notifications
You must be signed in to change notification settings - Fork 0
[MPT-14905] Fixed agreement attachments endpoints, created e2e tests #148
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
robcsegal
merged 1 commit into
main
from
MPT-14905-add-e-2-e-tests-for-commerce-agreements-attachments
Dec 5, 2025
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
There are no files selected for viewing
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
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
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,28 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def invalid_agreement_attachment_id(): | ||
| return "ATT-0000-0000-0000-0000" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def agreement_attachment_id(e2e_config): | ||
| return e2e_config["commerce.agreement.attachment.id"] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def agreement_attachment_factory(): | ||
| def factory( | ||
| name: str = "E2E Created Agreement Attachment", | ||
| attachment_type: str = "File", | ||
| license_key: str = "", | ||
| ): | ||
| return { | ||
| "name": name, | ||
| "description": name, | ||
| "type": attachment_type, | ||
| "licenseKey": license_key, | ||
| } | ||
|
|
||
| return factory |
85 changes: 85 additions & 0 deletions
85
tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.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,85 @@ | ||
| 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 created_agreement_attachment(agreement_attachments, agreement_attachment_factory, pdf_fd): | ||
| new_agreement_attachment_request_data = agreement_attachment_factory( | ||
| name="E2E Created Agreement Attachment", | ||
| ) | ||
| return await agreement_attachments.create(new_agreement_attachment_request_data, file=pdf_fd) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def agreement_attachments(async_mpt_ops, agreement_id): | ||
| return async_mpt_ops.commerce.agreements.attachments(agreement_id) | ||
|
|
||
|
|
||
| async def test_get_agreement_attachment_by_id(agreement_attachments, agreement_attachment_id): | ||
| result = await agreement_attachments.get(agreement_attachment_id) | ||
| assert result is not None | ||
|
|
||
|
|
||
| async def test_get_agreement_attachment_by_id_not_found( | ||
| agreement_attachments, invalid_agreement_attachment_id | ||
| ): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await agreement_attachments.get(invalid_agreement_attachment_id) | ||
|
|
||
|
|
||
| async def test_list_agreement_attachments(agreement_attachments): | ||
| limit = 10 | ||
|
|
||
| result = await agreement_attachments.fetch_page(limit=limit) | ||
|
|
||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| async def test_filter_agreement_attachments(agreement_attachments, agreement_attachment_id): | ||
| select_fields = ["-description"] | ||
| filtered_attachments = ( | ||
| agreement_attachments.filter(RQLQuery(id=agreement_attachment_id)) | ||
| .filter(RQLQuery(name="E2E Seeded Agreement Attachment")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = [att async for att in filtered_attachments.iterate()] | ||
|
|
||
| assert len(result) == 1 | ||
|
|
||
|
|
||
| def test_create_agreement_attachment(created_agreement_attachment): | ||
| result = created_agreement_attachment | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| async def test_update_agreement_attachment(agreement_attachments, created_agreement_attachment): | ||
| updated_name = "E2E Updated Agreement Attachment Name" | ||
| updated_attachment_data = { | ||
| "name": updated_name, | ||
| "description": updated_name, | ||
| } | ||
| attachment = created_agreement_attachment | ||
|
|
||
| result = await agreement_attachments.update(attachment.id, updated_attachment_data) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| async def test_delete_agreement_attachment(agreement_attachments, created_agreement_attachment): | ||
| result = created_agreement_attachment | ||
| await agreement_attachments.delete(result.id) | ||
|
|
||
|
|
||
| async def test_download_agreement_attachment(agreement_attachments, created_agreement_attachment): | ||
| attachment = created_agreement_attachment | ||
|
|
||
| result = await agreement_attachments.download(attachment.id) | ||
|
|
||
| assert result.file_contents is not None | ||
| assert result.filename == "empty.pdf" | ||
robcsegal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
85 changes: 85 additions & 0 deletions
85
tests/e2e/commerce/agreement/attachment/test_sync_agreement_attachment.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,85 @@ | ||
| 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_agreement_attachment(mpt_ops, agreement_attachment_factory, agreement_id, pdf_fd): | ||
| new_agreement_attachment_request_data = agreement_attachment_factory( | ||
| name="E2E Created Agreement Attachment", | ||
| ) | ||
| agreement_attachments = mpt_ops.commerce.agreements.attachments(agreement_id) | ||
| return agreement_attachments.create(new_agreement_attachment_request_data, file=pdf_fd) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def agreement_attachments(mpt_ops, agreement_id): | ||
| return mpt_ops.commerce.agreements.attachments(agreement_id) | ||
|
|
||
|
|
||
| def test_get_agreement_attachment_by_id(agreement_attachments, agreement_attachment_id): | ||
| result = agreement_attachments.get(agreement_attachment_id) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| def test_get_agreement_attachment_by_id_not_found( | ||
| agreement_attachments, invalid_agreement_attachment_id | ||
| ): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| agreement_attachments.get(invalid_agreement_attachment_id) | ||
|
|
||
|
|
||
| def test_list_agreement_attachments(agreement_attachments): | ||
| limit = 10 | ||
|
|
||
| result = agreement_attachments.fetch_page(limit=limit) | ||
|
|
||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| def test_filter_agreement_attachments(agreement_attachments, agreement_attachment_id): | ||
| select_fields = ["-description"] | ||
| filtered_attachments = ( | ||
| agreement_attachments.filter(RQLQuery(id=agreement_attachment_id)) | ||
| .filter(RQLQuery(name="E2E Seeded Agreement Attachment")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = list(filtered_attachments.iterate()) | ||
|
|
||
| assert len(result) == 1 | ||
|
|
||
|
|
||
| def test_create_agreement_attachment(created_agreement_attachment): | ||
| result = created_agreement_attachment | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| def test_update_agreement_attachment(agreement_attachments, created_agreement_attachment): | ||
| updated_name = "E2E Updated Agreement Attachment Name" | ||
| updated_attachment_data = { | ||
| "name": updated_name, | ||
| "description": updated_name, | ||
| } | ||
|
|
||
| result = agreement_attachments.update(created_agreement_attachment.id, updated_attachment_data) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| def test_delete_agreement_attachment(agreement_attachments, created_agreement_attachment): | ||
| result = created_agreement_attachment | ||
|
|
||
| agreement_attachments.delete(result.id) | ||
|
|
||
|
|
||
| def test_download_agreement_attachment(agreement_attachments, created_agreement_attachment): | ||
| result = agreement_attachments.download(created_agreement_attachment.id) | ||
|
|
||
| assert result.file_contents is not None | ||
| assert result.filename == "empty.pdf" | ||
robcsegal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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.