-
Notifications
You must be signed in to change notification settings - Fork 0
[MPT-14879] Added Accounts licensees e2e tests #124
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-14879-add-e-2-e-tests-for-licensees-endpoints
Nov 20, 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,17 +1,20 @@ | ||
| { | ||
| "accounts.seller.id": "SEL-7310-3075", | ||
| "accounts.account.id": "ACC-9042-0088", | ||
| "accounts.api_token.id": "TKN-8857-1729", | ||
| "accounts.buyer.account.id": "ACC-1086-6867", | ||
| "accounts.buyer.id": "BUY-1591-2112", | ||
| "accounts.user_group.id": "UGR-6822-0561", | ||
| "accounts.licensee.account.id": "ACC-1086-6867", | ||
| "accounts.licensee.group.id": "UGR-2757-7226", | ||
| "accounts.licensee.id": "LCE-5758-4071-6507", | ||
| "accounts.module.id": "MOD-1756", | ||
| "accounts.module.name": "Access Management", | ||
| "accounts.seller.id": "SEL-7310-3075", | ||
| "accounts.user_group.id": "UGR-6822-0561", | ||
| "catalog.item.id": "ITM-7255-3950-0001", | ||
| "catalog.product.document.id": "PDC-7255-3950-0001", | ||
| "catalog.product.id": "PRD-7255-3950", | ||
| "catalog.product.parameter_group.id": "PGR-7255-3950-0001", | ||
| "catalog.product.item_group.id": "IGR-7255-3950-0001", | ||
| "catalog.product.parameter.id": "PAR-7255-3950-0016", | ||
| "catalog.product.document.id": "PDC-7255-3950-0001", | ||
| "catalog.item.id": "ITM-7255-3950-0001", | ||
| "catalog.unit.id": "UNT-1229", | ||
| "accounts.api_token.id": "TKN-8857-1729" | ||
| "catalog.product.parameter_group.id": "PGR-7255-3950-0001", | ||
| "catalog.unit.id": "UNT-1229" | ||
| } |
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,114 @@ | ||
| 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_licensee(async_mpt_client, licensee_factory, account_icon): | ||
| new_licensee_request_data = licensee_factory(name="E2E Created licensee") | ||
|
|
||
| new_licensee = await async_mpt_client.accounts.licensees.create( | ||
| new_licensee_request_data, logo=account_icon | ||
| ) | ||
|
|
||
| yield new_licensee | ||
|
|
||
| try: | ||
| await async_mpt_client.accounts.licensees.delete(new_licensee.id) | ||
| except MPTAPIError as error: | ||
| print(f"TEARDOWN - Unable to delete licensee: {error.title}") # noqa: WPS421 | ||
|
|
||
|
|
||
| async def test_get_licensee_by_id(async_mpt_client, licensee_id): | ||
| licensee = await async_mpt_client.accounts.licensees.get(licensee_id) | ||
| assert licensee is not None | ||
|
|
||
|
|
||
| async def test_list_licensees(async_mpt_client): | ||
| limit = 10 | ||
| licensees = await async_mpt_client.accounts.licensees.fetch_page(limit=limit) | ||
| assert len(licensees) > 0 | ||
|
|
||
|
|
||
| async def test_get_licensee_by_id_not_found(async_mpt_client, invalid_licensee_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_client.accounts.licensees.get(invalid_licensee_id) | ||
|
|
||
|
|
||
| async def test_filter_licensees(async_mpt_client, licensee_id): | ||
| select_fields = ["-address"] | ||
|
|
||
| async_filtered_licensees = ( | ||
| async_mpt_client.accounts.licensees.filter(RQLQuery(id=licensee_id)) | ||
| .filter(RQLQuery(name="E2E Seeded Licensee")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| licensees = [ | ||
| filtered_licensee async for filtered_licensee in async_filtered_licensees.iterate() | ||
| ] | ||
|
|
||
| assert len(licensees) == 1 | ||
|
|
||
|
|
||
| def test_create_licensee(async_created_licensee): | ||
| assert async_created_licensee is not None | ||
|
|
||
|
|
||
| async def test_delete_licensee(async_mpt_client, async_created_licensee): | ||
| await async_mpt_client.accounts.licensees.delete(async_created_licensee.id) | ||
|
|
||
|
|
||
| async def test_delete_licensee_not_found(async_mpt_client, invalid_licensee_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_client.accounts.licensees.delete(invalid_licensee_id) | ||
|
|
||
|
|
||
| async def test_update_licensee( | ||
| async_mpt_client, licensee_factory, account_icon, async_created_licensee | ||
| ): | ||
| updated_licensee_data = licensee_factory(name="E2E Updated Licensee") | ||
|
|
||
| updated_licensee = await async_mpt_client.accounts.licensees.update( | ||
| async_created_licensee.id, updated_licensee_data, logo=account_icon | ||
| ) | ||
|
|
||
| assert updated_licensee is not None | ||
|
|
||
|
|
||
| async def test_update_licensee_not_found( | ||
| async_mpt_client, licensee_factory, account_icon, invalid_licensee_id | ||
| ): | ||
| updated_licensee_data = licensee_factory(name="Nonexistent Licensee") | ||
|
|
||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_client.accounts.licensees.update( | ||
| invalid_licensee_id, updated_licensee_data, logo=account_icon | ||
| ) | ||
|
|
||
|
|
||
| async def test_licensee_disable(async_mpt_client, async_created_licensee): | ||
| disabled_licensee = await async_mpt_client.accounts.licensees.disable(async_created_licensee.id) | ||
|
|
||
| assert disabled_licensee is not None | ||
|
|
||
|
|
||
| async def test_licensee_disable_not_found(async_mpt_client, invalid_licensee_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_client.accounts.licensees.disable(invalid_licensee_id) | ||
|
|
||
|
|
||
| async def test_licensee_enable(async_mpt_client, async_created_licensee): | ||
| await async_mpt_client.accounts.licensees.disable(async_created_licensee.id) | ||
|
|
||
| enabled_licensee = await async_mpt_client.accounts.licensees.enable(async_created_licensee.id) | ||
|
|
||
| assert enabled_licensee is not None | ||
|
|
||
|
|
||
| async def test_licensee_enable_not_found(async_mpt_client, invalid_licensee_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_client.accounts.licensees.enable(invalid_licensee_id) |
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.
Uh oh!
There was an error while loading. Please reload this page.