-
Notifications
You must be signed in to change notification settings - Fork 0
MPT-14899 E2E tests for catalog pricing-policies #132
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
albertsola
merged 1 commit into
main
from
e2e/catalog/MPT-14899-Add-E2E-tests-for-catalog-pricing-policies
Nov 25, 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
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
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,23 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def buyer_id(e2e_config): | ||
| return e2e_config["accounts.buyer.account.id"] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def pricing_policy_data(buyer_id, product_id): | ||
| return { | ||
| "name": "e2e - pricing policy please delete", | ||
| "description": "Test pricing policy description", | ||
| "client": {"id": buyer_id}, | ||
| "product": {"id": product_id}, | ||
| "eligibility": {"client": True, "partner": False}, | ||
| "margin": "0.20", | ||
| } | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def pricing_policy_id(e2e_config): | ||
| return e2e_config.get("catalog.pricing_policy.id") |
83 changes: 83 additions & 0 deletions
83
tests/e2e/catalog/pricing_policies/test_async_pricing_policies.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,83 @@ | ||
| 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 async_pricing_policies_service(async_mpt_ops): | ||
| return async_mpt_ops.catalog.pricing_policies | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def async_created_pricing_policy(async_pricing_policies_service, pricing_policy_data): | ||
| policy = await async_pricing_policies_service.create(pricing_policy_data) | ||
|
|
||
| yield policy | ||
|
|
||
| try: | ||
| await async_pricing_policies_service.delete(policy.id) | ||
| except MPTAPIError as error: | ||
| print(f"TEARDOWN - Unable to delete pricing policy {policy.id}: {error.title}") | ||
|
|
||
|
|
||
| def test_create_pricing_policy(async_created_pricing_policy, pricing_policy_data): | ||
| assert async_created_pricing_policy.name == pricing_policy_data["name"] | ||
|
|
||
|
|
||
| async def test_get_pricing_policy(async_pricing_policies_service, async_created_pricing_policy): | ||
| fetched = await async_pricing_policies_service.get(async_created_pricing_policy.id) | ||
| assert fetched.id == async_created_pricing_policy.id | ||
|
|
||
|
|
||
| async def test_get_pricing_policy_by_id( | ||
| async_pricing_policies_service, async_created_pricing_policy | ||
| ): | ||
| fetched = await async_pricing_policies_service.get(async_created_pricing_policy.id) | ||
| assert fetched.id == async_created_pricing_policy.id | ||
|
|
||
|
|
||
| async def test_iterate_pricing_policies( | ||
| async_pricing_policies_service, async_created_pricing_policy | ||
| ): | ||
| policies = [policy async for policy in async_pricing_policies_service.iterate()] | ||
| assert any(policy.id == async_created_pricing_policy.id for policy in policies) | ||
|
|
||
|
|
||
| async def test_filter_pricing_policies( | ||
| async_pricing_policies_service, async_created_pricing_policy | ||
| ): | ||
| target_id = async_created_pricing_policy.id | ||
| select_fields = ["-description"] | ||
| filtered = async_pricing_policies_service.filter(RQLQuery(id=target_id)).select(*select_fields) | ||
| policies = [policy async for policy in filtered.iterate()] | ||
| assert len(policies) == 1 | ||
| assert policies[0].id == target_id | ||
|
|
||
|
|
||
| async def test_activate_deactivate_pricing_policy( | ||
| async_pricing_policies_service, async_created_pricing_policy | ||
| ): | ||
| deactivate = await async_pricing_policies_service.disable(async_created_pricing_policy.id) | ||
| assert deactivate.id == async_created_pricing_policy.id | ||
|
|
||
| activated = await async_pricing_policies_service.activate(async_created_pricing_policy.id) | ||
| assert activated.id == async_created_pricing_policy.id | ||
|
|
||
|
|
||
| async def test_delete_pricing_policy(async_pricing_policies_service, async_created_pricing_policy): | ||
| await async_pricing_policies_service.delete(async_created_pricing_policy.id) # act | ||
|
|
||
|
|
||
| async def test_get_pricing_policy_not_found(async_pricing_policies_service): | ||
| bogus_id = "PPY-0000-NOTFOUND" | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_pricing_policies_service.get(bogus_id) | ||
|
|
||
|
|
||
| async def test_create_pricing_policy_invalid_data(async_pricing_policies_service): | ||
| invalid_data = {"name": "e2e - delete me", "description": "invalid data"} | ||
| with pytest.raises(MPTAPIError, match=r"400 One or more validation errors occurred"): | ||
| await async_pricing_policies_service.create(invalid_data) | ||
77 changes: 77 additions & 0 deletions
77
tests/e2e/catalog/pricing_policies/test_sync_pricing_policies.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,77 @@ | ||
| 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 pricing_policies_service(mpt_ops): | ||
| return mpt_ops.catalog.pricing_policies | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def created_pricing_policy(pricing_policies_service, pricing_policy_data): | ||
| policy = pricing_policies_service.create(pricing_policy_data) | ||
|
|
||
| yield policy | ||
|
|
||
| try: | ||
| pricing_policies_service.delete(policy.id) | ||
| except MPTAPIError as error: | ||
| print(f"TEARDOWN - Unable to delete pricing policy {policy.id}: {error.title}") | ||
|
|
||
|
|
||
| def test_create_pricing_policy(created_pricing_policy, pricing_policy_data): | ||
| assert created_pricing_policy.name == pricing_policy_data["name"] | ||
|
|
||
|
|
||
| def test_get_pricing_policy(pricing_policies_service, created_pricing_policy): | ||
| fetched = pricing_policies_service.get(created_pricing_policy.id) | ||
| assert fetched.id == created_pricing_policy.id | ||
|
|
||
|
|
||
| def test_get_pricing_policy_by_id(pricing_policies_service, pricing_policy_id): | ||
| if not pricing_policy_id: | ||
| pytest.skip("No pricing_policy_id configured") | ||
| fetched = pricing_policies_service.get(pricing_policy_id) | ||
| assert fetched.id == pricing_policy_id | ||
|
|
||
|
|
||
| def test_iterate_pricing_policies(pricing_policies_service, created_pricing_policy): | ||
| policies = list(pricing_policies_service.iterate()) | ||
| assert any(policy.id == created_pricing_policy.id for policy in policies) | ||
|
|
||
|
|
||
| def test_filter_pricing_policies(pricing_policies_service, created_pricing_policy): | ||
| target_id = created_pricing_policy.id | ||
| select_fields = ["-description"] | ||
| filtered = pricing_policies_service.filter(RQLQuery(id=target_id)).select(*select_fields) | ||
| policies = list(filtered.iterate()) | ||
| assert len(policies) == 1 | ||
| assert policies[0].id == target_id | ||
|
|
||
|
|
||
| def test_activate_deactivate_pricing_policy(pricing_policies_service, created_pricing_policy): | ||
| deactivate = pricing_policies_service.disable(created_pricing_policy.id) | ||
| assert deactivate.id == created_pricing_policy.id | ||
|
|
||
| activated = pricing_policies_service.activate(deactivate.id) | ||
| assert activated.id == created_pricing_policy.id | ||
|
|
||
|
|
||
| def test_delete_pricing_policy(pricing_policies_service, created_pricing_policy): | ||
| pricing_policies_service.delete(created_pricing_policy.id) # act | ||
|
|
||
|
|
||
| def test_get_pricing_policy_not_found(pricing_policies_service): | ||
| bogus_id = "PPY-0000-NOTFOUND" | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| pricing_policies_service.get(bogus_id) | ||
|
|
||
|
|
||
| def test_create_pricing_policy_invalid_data(pricing_policies_service): | ||
| invalid_data = {"name": "e2e - delete me", "description": "invalid data"} | ||
| with pytest.raises(MPTAPIError, match=r"400 One or more validation errors occurred"): | ||
| pricing_policies_service.create(invalid_data) |
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.
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.
AAA :-)