-
Notifications
You must be signed in to change notification settings - Fork 0
[MPT-14864] Added Accounts accounts e2e CRUD and state endpoints tests #115
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-14864-add-e-2-e-tests-for-accounts-endpoints-for-crud-and-state-operations
Nov 12, 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "catalog.product.id": "PRD-7255-3950", | ||
| "accounts.seller.id": "SEL-7310-3075", | ||
| "catalog.product.parameter_group.id": "PGR-7255-3950-0001" | ||
| "catalog.product.parameter_group.id": "PGR-7255-3950-0001", | ||
| "accounts.account.id": "ACC-9042-0088" | ||
| } |
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,108 @@ | ||
| 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_account(logger, async_mpt_ops, account, account_icon): | ||
| account_data = account() | ||
|
|
||
| res_account = await async_mpt_ops.accounts.accounts.create(account_data, logo=account_icon) | ||
|
|
||
| yield res_account | ||
|
|
||
| try: | ||
| await async_mpt_ops.accounts.accounts.deactivate(res_account.id) | ||
| except MPTAPIError as error: | ||
| print("TEARDOWN - Unable to deactivate account: %s", error.title) # noqa: WPS421 | ||
|
|
||
|
|
||
| async def test_get_account_by_id_not_found(async_mpt_ops): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_ops.accounts.accounts.get("INVALID-ID") | ||
|
|
||
|
|
||
| async def test_get_account_by_id(async_mpt_ops, account_id): | ||
| account = await async_mpt_ops.accounts.accounts.get(account_id) | ||
| assert account is not None | ||
|
|
||
|
|
||
| async def test_list_accounts(async_mpt_ops): | ||
| limit = 10 | ||
| accounts_page = await async_mpt_ops.accounts.accounts.fetch_page(limit=limit) | ||
| assert len(accounts_page) > 0 | ||
|
|
||
|
|
||
| def test_create_account(async_created_account): | ||
| account = async_created_account | ||
| assert account is not None | ||
|
|
||
|
|
||
| async def test_update_account(async_mpt_ops, async_created_account, account, account_icon): | ||
| updated_data = account(name="Updated Account Name") | ||
|
|
||
| updated_account = await async_mpt_ops.accounts.accounts.update( | ||
| async_created_account.id, updated_data, logo=account_icon | ||
| ) | ||
|
|
||
| assert updated_account is not None | ||
|
|
||
|
|
||
| async def test_update_account_invalid_data( | ||
| async_mpt_ops, account, async_created_account, account_icon | ||
| ): | ||
| updated_data = account(name="") | ||
|
|
||
| with pytest.raises(MPTAPIError, match=r"400 Bad Request"): | ||
| await async_mpt_ops.accounts.accounts.update( | ||
| async_created_account.id, updated_data, logo=account_icon | ||
| ) | ||
|
|
||
|
|
||
| async def test_update_account_not_found(async_mpt_ops, account, invalid_account_id, account_icon): | ||
| non_existent_account = account(name="Non Existent Account") | ||
|
|
||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_ops.accounts.accounts.update( | ||
| invalid_account_id, non_existent_account, logo=account_icon | ||
| ) | ||
|
|
||
|
|
||
| async def test_account_enable(async_mpt_ops, account, async_created_account): | ||
| await async_mpt_ops.accounts.accounts.disable(async_created_account.id) | ||
|
|
||
| account = await async_mpt_ops.accounts.accounts.enable(async_created_account.id) | ||
|
|
||
| assert account is not None | ||
|
|
||
|
|
||
| async def test_account_enable_not_found(async_mpt_ops, invalid_account_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_ops.accounts.accounts.enable(invalid_account_id) | ||
|
|
||
|
|
||
| async def test_account_disable(async_mpt_ops, async_created_account): | ||
| account = await async_mpt_ops.accounts.accounts.disable(async_created_account.id) | ||
|
|
||
| assert account is not None | ||
|
|
||
|
|
||
| async def test_account_disable_not_found(async_mpt_ops, invalid_account_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_ops.accounts.accounts.disable(invalid_account_id) | ||
|
|
||
|
|
||
| async def test_account_rql_filter(async_mpt_ops, account_id): | ||
| selected_fields = ["-address"] | ||
| filtered_accounts = ( | ||
| async_mpt_ops.accounts.accounts.filter(RQLQuery(id=account_id)) | ||
| .filter(RQLQuery(name="Test Api Client Vendor")) | ||
| .select(*selected_fields) | ||
| ) | ||
|
|
||
| accounts = [account async for account in filtered_accounts.iterate()] | ||
|
|
||
| assert len(accounts) > 0 | ||
Oops, something went wrong.
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.
👍