-
Notifications
You must be signed in to change notification settings - Fork 0
[MPT-14923] Added e2e tests for commerce credit memos #191
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-14923-add-e-2-e-tests-for-billing-credit-memos
Jan 12, 2026
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def invalid_credit_memo_id(): | ||
| return "CRD-0000-0000-0000-0000" |
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,59 @@ | ||
| 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 credit_memos(async_mpt_ops): | ||
| limit = 1 | ||
| return await async_mpt_ops.billing.credit_memos.fetch_page(limit=limit) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def credit_memo(credit_memos): | ||
| if credit_memos: | ||
| return credit_memos[0] | ||
| return None | ||
|
|
||
|
|
||
| async def test_get_credit_memo_by_id(async_mpt_ops, credit_memo): | ||
| if credit_memo is None: | ||
| pytest.skip("No credit memos available to test retrieval by ID.") | ||
| credit_memo_id = credit_memo.id | ||
|
|
||
| result = await async_mpt_ops.billing.credit_memos.get(credit_memo_id) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| async def test_get_credit_memo_by_id_not_found(async_mpt_ops, invalid_credit_memo_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_ops.billing.credit_memos.get(invalid_credit_memo_id) | ||
|
|
||
|
|
||
| async def test_list_credit_memos(async_mpt_ops): | ||
| limit = 10 | ||
|
|
||
| result = await async_mpt_ops.billing.credit_memos.fetch_page(limit=limit) | ||
|
|
||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| async def test_filter_credit_memos(async_mpt_ops, credit_memo): | ||
| if credit_memo is None: | ||
| pytest.skip("No credit memos available to test filtering.") | ||
| credit_memo_id = credit_memo.id | ||
| credit_memo_status = credit_memo.status | ||
| select_fields = ["-vendor"] | ||
| filtered_credit_memos = ( | ||
| async_mpt_ops.billing.credit_memos.filter(RQLQuery(id=credit_memo_id)) | ||
| .filter(RQLQuery(status=credit_memo_status)) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = [credit_memo async for credit_memo in filtered_credit_memos.iterate()] | ||
|
|
||
| assert len(result) == 1 |
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,59 @@ | ||
| 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 credit_memos(mpt_ops): | ||
| limit = 1 | ||
| return mpt_ops.billing.credit_memos.fetch_page(limit=limit) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def credit_memo(credit_memos): | ||
| if credit_memos: | ||
| return credit_memos[0] | ||
| return None | ||
|
|
||
|
|
||
| def test_get_credit_memo_by_id(mpt_ops, credit_memo): | ||
| if credit_memo is None: | ||
| pytest.skip("No credit memos available to test retrieval by ID.") | ||
| credit_memo_id = credit_memo.id | ||
|
|
||
| result = mpt_ops.billing.credit_memos.get(credit_memo_id) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| def test_get_credit_memo_by_id_not_found(mpt_ops, invalid_credit_memo_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| mpt_ops.billing.credit_memos.get(invalid_credit_memo_id) | ||
|
|
||
|
|
||
| def test_list_credit_memos(mpt_ops): | ||
| limit = 10 | ||
|
|
||
| result = mpt_ops.billing.credit_memos.fetch_page(limit=limit) | ||
|
|
||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| def test_filter_credit_memos(mpt_ops, credit_memo): | ||
| if credit_memo is None: | ||
| pytest.skip("No credit memos available to test filtering.") | ||
| credit_memo_id = credit_memo.id | ||
| credit_memo_status = credit_memo.status | ||
| select_fields = ["-vendor"] | ||
| filtered_credit_memos = ( | ||
| mpt_ops.billing.credit_memos.filter(RQLQuery(id=credit_memo_id)) | ||
| .filter(RQLQuery(status=credit_memo_status)) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = list(filtered_credit_memos.iterate()) | ||
|
|
||
| assert len(result) == 1 | ||
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.