diff --git a/e2e_config.test.json b/e2e_config.test.json index 4015749a..688e2ee6 100644 --- a/e2e_config.test.json +++ b/e2e_config.test.json @@ -12,5 +12,6 @@ "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" + "catalog.unit.id": "UNT-1229", + "accounts.api_token.id": "TKN-8857-1729" } diff --git a/tests/e2e/accounts/account/test_async_account.py b/tests/e2e/accounts/account/test_async_account.py index 16b266db..ca12d72a 100644 --- a/tests/e2e/accounts/account/test_async_account.py +++ b/tests/e2e/accounts/account/test_async_account.py @@ -7,8 +7,8 @@ @pytest.fixture -async def async_created_account(logger, async_mpt_ops, account, account_icon): - account_data = account() +async def async_created_account(logger, async_mpt_ops, account_factory, account_icon): + account_data = account_factory() res_account = await async_mpt_ops.accounts.accounts.create(account_data, logo=account_icon) @@ -41,8 +41,8 @@ def test_create_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") +async def test_update_account(async_mpt_ops, async_created_account, account_factory, account_icon): + updated_data = account_factory(name="Updated Account Name") updated_account = await async_mpt_ops.accounts.accounts.update( async_created_account.id, updated_data, logo=account_icon @@ -52,9 +52,9 @@ async def test_update_account(async_mpt_ops, async_created_account, account, acc async def test_update_account_invalid_data( - async_mpt_ops, account, async_created_account, account_icon + async_mpt_ops, account_factory, async_created_account, account_icon ): - updated_data = account(name="") + updated_data = account_factory(name="") with pytest.raises(MPTAPIError, match=r"400 Bad Request"): await async_mpt_ops.accounts.accounts.update( @@ -62,8 +62,10 @@ async def test_update_account_invalid_data( ) -async def test_update_account_not_found(async_mpt_ops, account, invalid_account_id, account_icon): - non_existent_account = account(name="Non Existent Account") +async def test_update_account_not_found( + async_mpt_ops, account_factory, invalid_account_id, account_icon +): + non_existent_account = account_factory(name="Non Existent Account") with pytest.raises(MPTAPIError, match=r"404 Not Found"): await async_mpt_ops.accounts.accounts.update( @@ -71,7 +73,7 @@ async def test_update_account_not_found(async_mpt_ops, account, invalid_account_ ) -async def test_account_enable(async_mpt_ops, account, async_created_account): +async def test_account_enable(async_mpt_ops, account_factory, 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) diff --git a/tests/e2e/accounts/account/test_sync_account.py b/tests/e2e/accounts/account/test_sync_account.py index f5764391..57071088 100644 --- a/tests/e2e/accounts/account/test_sync_account.py +++ b/tests/e2e/accounts/account/test_sync_account.py @@ -7,8 +7,8 @@ @pytest.fixture -def created_account(logger, mpt_ops, account, account_icon): - account_data = account() +def created_account(logger, mpt_ops, account_factory, account_icon): + account_data = account_factory() res_account = mpt_ops.accounts.accounts.create(account_data, logo=account_icon) @@ -41,8 +41,8 @@ def test_create_account(created_account): assert account is not None -def test_update_account(mpt_ops, created_account, account, account_icon): - updated_data = account(name="Updated Account Name") +def test_update_account(mpt_ops, created_account, account_factory, account_icon): + updated_data = account_factory(name="Updated Account Name") updated_account = mpt_ops.accounts.accounts.update( created_account.id, updated_data, logo=account_icon @@ -51,15 +51,15 @@ def test_update_account(mpt_ops, created_account, account, account_icon): assert updated_account is not None -def test_update_account_invalid_data(mpt_ops, account, created_account, account_icon): - updated_data = account(name="") +def test_update_account_invalid_data(mpt_ops, account_factory, created_account, account_icon): + updated_data = account_factory(name="") with pytest.raises(MPTAPIError, match=r"400 Bad Request"): mpt_ops.accounts.accounts.update(created_account.id, updated_data, logo=account_icon) -def test_update_account_not_found(mpt_ops, account, invalid_account_id, account_icon): - non_existent_account = account(name="Non Existent Account") +def test_update_account_not_found(mpt_ops, account_factory, invalid_account_id, account_icon): + non_existent_account = account_factory(name="Non Existent Account") with pytest.raises(MPTAPIError, match=r"404 Not Found"): mpt_ops.accounts.accounts.update( @@ -67,7 +67,7 @@ def test_update_account_not_found(mpt_ops, account, invalid_account_id, account_ ) -def test_account_enable(mpt_ops, account, created_account): +def test_account_enable(mpt_ops, account_factory, created_account): mpt_ops.accounts.accounts.disable(created_account.id) account = mpt_ops.accounts.accounts.enable(created_account.id) diff --git a/tests/e2e/accounts/api_tokens/test_async_api_tokens.py b/tests/e2e/accounts/api_tokens/test_async_api_tokens.py new file mode 100644 index 00000000..a9556d9e --- /dev/null +++ b/tests/e2e/accounts/api_tokens/test_async_api_tokens.py @@ -0,0 +1,110 @@ +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_api_token(async_mpt_vendor, api_token_factory): + new_api_token_request_data = api_token_factory() + created_api_token = await async_mpt_vendor.accounts.api_tokens.create( + new_api_token_request_data + ) + + yield created_api_token + + try: + await async_mpt_vendor.accounts.api_tokens.delete(created_api_token.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete api token: {error.title}") # noqa: WPS421 + + +async def test_get_api_token_by_id(async_mpt_vendor, api_token_id): + api_token = await async_mpt_vendor.accounts.api_tokens.get(api_token_id) + assert api_token is not None + + +async def test_list_api_tokens(async_mpt_vendor): + limit = 10 + api_tokens = await async_mpt_vendor.accounts.api_tokens.fetch_page(limit=limit) + assert len(api_tokens) > 0 + + +async def test_get_api_token_by_id_not_found(async_mpt_vendor, invalid_api_token_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + await async_mpt_vendor.accounts.api_tokens.get(invalid_api_token_id) + + +async def test_filter_api_tokens(async_mpt_vendor, api_token_id): + select_fields = ["-description"] + + filtered_api_tokens = ( + async_mpt_vendor.accounts.api_tokens.filter(RQLQuery(id=api_token_id)) + .filter(RQLQuery(name="E2E Seeded Token")) + .select(*select_fields) + ) + + api_tokens = [filtered_api_token async for filtered_api_token in filtered_api_tokens.iterate()] + + assert len(api_tokens) == 1 + + +def test_create_api_token(created_api_token): + new_api_token = created_api_token + assert new_api_token is not None + + +async def test_delete_api_token(async_mpt_vendor, created_api_token): + await async_mpt_vendor.accounts.api_tokens.delete(created_api_token.id) + + +async def test_delete_api_token_not_found(async_mpt_vendor, invalid_api_token_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + await async_mpt_vendor.accounts.api_tokens.delete(invalid_api_token_id) + + +async def test_update_api_token(async_mpt_vendor, api_token_factory, created_api_token): + updated_api_token_data = api_token_factory(name="E2E Updated API Token") + + updated_api_token = await async_mpt_vendor.accounts.api_tokens.update( + created_api_token.id, updated_api_token_data + ) + + assert updated_api_token is not None + + +async def test_update_api_token_not_found( + async_mpt_vendor, api_token_factory, invalid_api_token_id +): + updated_api_token_data = api_token_factory(name="Nonexistent API Token") + + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + await async_mpt_vendor.accounts.api_tokens.update( + invalid_api_token_id, updated_api_token_data + ) + + +async def test_api_token_disable(async_mpt_vendor, created_api_token): + disabled_api_token = await async_mpt_vendor.accounts.api_tokens.disable(created_api_token.id) + + assert disabled_api_token is not None + + +async def test_api_token_disable_not_found(async_mpt_vendor, invalid_api_token_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + await async_mpt_vendor.accounts.api_tokens.disable(invalid_api_token_id) + + +async def test_api_token_enable(async_mpt_vendor, created_api_token): + await async_mpt_vendor.accounts.api_tokens.disable(created_api_token.id) + + enabled_api_token = await async_mpt_vendor.accounts.api_tokens.enable(created_api_token.id) + + assert enabled_api_token is not None + + +async def test_api_token_enable_not_found(async_mpt_vendor, invalid_api_token_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + await async_mpt_vendor.accounts.api_tokens.enable(invalid_api_token_id) diff --git a/tests/e2e/accounts/api_tokens/test_sync_api_tokens.py b/tests/e2e/accounts/api_tokens/test_sync_api_tokens.py new file mode 100644 index 00000000..98179c5d --- /dev/null +++ b/tests/e2e/accounts/api_tokens/test_sync_api_tokens.py @@ -0,0 +1,104 @@ +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_api_token(mpt_vendor, api_token_factory): + new_api_token_request_data = api_token_factory() + created_api_token = mpt_vendor.accounts.api_tokens.create(new_api_token_request_data) + + yield created_api_token + + try: + mpt_vendor.accounts.api_tokens.delete(created_api_token.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete api token: {error.title}") # noqa: WPS421 + + +def test_get_api_token_by_id(mpt_vendor, api_token_id): + api_token = mpt_vendor.accounts.api_tokens.get(api_token_id) + assert api_token is not None + + +def test_list_api_tokens(mpt_vendor): + limit = 10 + api_tokens = mpt_vendor.accounts.api_tokens.fetch_page(limit=limit) + assert len(api_tokens) > 0 + + +def test_get_api_token_by_id_not_found(mpt_vendor, invalid_api_token_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + mpt_vendor.accounts.api_tokens.get(invalid_api_token_id) + + +def test_filter_api_tokens(mpt_vendor, api_token_id): + select_fields = ["-name"] + + filtered_api_tokens = ( + mpt_vendor.accounts.api_tokens.filter(RQLQuery(id=api_token_id)) + .filter(RQLQuery(name="E2E Seeded Token")) + .select(*select_fields) + ) + + api_tokens = list(filtered_api_tokens.iterate()) + + assert len(api_tokens) == 1 + + +def test_create_api_token(created_api_token): + new_api_token = created_api_token + assert new_api_token is not None + + +def test_delete_api_token(mpt_vendor, created_api_token): + mpt_vendor.accounts.api_tokens.delete(created_api_token.id) + + +def test_delete_api_token_not_found(mpt_vendor, invalid_api_token_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + mpt_vendor.accounts.api_tokens.delete(invalid_api_token_id) + + +def test_update_api_token(mpt_vendor, api_token_factory, created_api_token): + updated_api_token_data = api_token_factory(name="E2E Updated API Token") + + updated_api_token = mpt_vendor.accounts.api_tokens.update( + created_api_token.id, updated_api_token_data + ) + + assert updated_api_token is not None + + +def test_update_api_token_not_found(mpt_vendor, api_token_factory, invalid_api_token_id): + updated_api_token_data = api_token_factory(name="Nonexistent API Token") + + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + mpt_vendor.accounts.api_tokens.update(invalid_api_token_id, updated_api_token_data) + + +def test_api_token_disable(mpt_vendor, created_api_token): + disabled_api_token = mpt_vendor.accounts.api_tokens.disable(created_api_token.id) + + assert disabled_api_token is not None + + +def test_api_token_disable_not_found(mpt_vendor, invalid_api_token_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + mpt_vendor.accounts.api_tokens.disable(invalid_api_token_id) + + +def test_api_token_enable(mpt_vendor, created_api_token): + mpt_vendor.accounts.api_tokens.disable(created_api_token.id) + + enabled_api_token = mpt_vendor.accounts.api_tokens.enable(created_api_token.id) + + assert enabled_api_token is not None + + +def test_api_token_enable_not_found(mpt_vendor, invalid_api_token_id): + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + mpt_vendor.accounts.api_tokens.enable(invalid_api_token_id) diff --git a/tests/e2e/accounts/buyers/test_async_buyers.py b/tests/e2e/accounts/buyers/test_async_buyers.py index c1abdcf5..39e327ea 100644 --- a/tests/e2e/accounts/buyers/test_async_buyers.py +++ b/tests/e2e/accounts/buyers/test_async_buyers.py @@ -7,8 +7,8 @@ @pytest.fixture -async def async_created_buyer(async_mpt_ops, buyer, buyer_account_id, account_icon): - new_buyer_request_data = buyer( +async def async_created_buyer(async_mpt_ops, buyer_factory, buyer_account_id, account_icon): + new_buyer_request_data = buyer_factory( name="E2E Created Buyer", account_id=buyer_account_id, ) @@ -69,9 +69,9 @@ async def test_delete_buyer_not_found(async_mpt_ops, invalid_buyer_id): async def test_update_buyer( - async_mpt_ops, buyer, buyer_account_id, account_icon, async_created_buyer + async_mpt_ops, buyer_factory, buyer_account_id, account_icon, async_created_buyer ): - updated_buyer_data = buyer(name="E2E Updated Buyer", account_id=buyer_account_id) + updated_buyer_data = buyer_factory(name="E2E Updated Buyer", account_id=buyer_account_id) updated_buyer = await async_mpt_ops.accounts.buyers.update( async_created_buyer.id, updated_buyer_data, logo=account_icon @@ -81,9 +81,9 @@ async def test_update_buyer( async def test_update_buyer_not_found( - async_mpt_ops, buyer, buyer_account_id, account_icon, invalid_buyer_id + async_mpt_ops, buyer_factory, buyer_account_id, account_icon, invalid_buyer_id ): - updated_buyer_data = buyer(name="Nonexistent Buyer", account_id=buyer_account_id) + updated_buyer_data = buyer_factory(name="Nonexistent Buyer", account_id=buyer_account_id) with pytest.raises(MPTAPIError, match=r"404 Not Found"): await async_mpt_ops.accounts.buyers.update( diff --git a/tests/e2e/accounts/buyers/test_sync_buyers.py b/tests/e2e/accounts/buyers/test_sync_buyers.py index 3c7c88fa..36c10750 100644 --- a/tests/e2e/accounts/buyers/test_sync_buyers.py +++ b/tests/e2e/accounts/buyers/test_sync_buyers.py @@ -7,8 +7,8 @@ @pytest.fixture -def created_buyer(mpt_ops, buyer, buyer_account_id, account_icon): - new_buyer_request_data = buyer( +def created_buyer(mpt_ops, buyer_factory, buyer_account_id, account_icon): + new_buyer_request_data = buyer_factory( name="E2E Created Buyer", account_id=buyer_account_id, ) @@ -67,8 +67,8 @@ def test_delete_buyer_not_found(mpt_ops, invalid_buyer_id): mpt_ops.accounts.buyers.delete(invalid_buyer_id) -def test_update_buyer(mpt_ops, buyer, buyer_account_id, account_icon, created_buyer): - updated_buyer_data = buyer(name="E2E Updated Buyer", account_id=buyer_account_id) +def test_update_buyer(mpt_ops, buyer_factory, buyer_account_id, account_icon, created_buyer): + updated_buyer_data = buyer_factory(name="E2E Updated Buyer", account_id=buyer_account_id) updated_buyer = mpt_ops.accounts.buyers.update( created_buyer.id, updated_buyer_data, logo=account_icon @@ -77,8 +77,10 @@ def test_update_buyer(mpt_ops, buyer, buyer_account_id, account_icon, created_bu assert updated_buyer is not None -def test_update_buyer_not_found(mpt_ops, buyer, buyer_account_id, account_icon, invalid_buyer_id): - updated_buyer_data = buyer(name="Nonexistent Buyer", account_id=buyer_account_id) +def test_update_buyer_not_found( + mpt_ops, buyer_factory, buyer_account_id, account_icon, invalid_buyer_id +): + updated_buyer_data = buyer_factory(name="Nonexistent Buyer", account_id=buyer_account_id) with pytest.raises(MPTAPIError, match=r"404 Not Found"): mpt_ops.accounts.buyers.update(invalid_buyer_id, updated_buyer_data, logo=account_icon) diff --git a/tests/e2e/accounts/conftest.py b/tests/e2e/accounts/conftest.py index 67229261..31dbcf61 100644 --- a/tests/e2e/accounts/conftest.py +++ b/tests/e2e/accounts/conftest.py @@ -21,7 +21,7 @@ def currencies(): @pytest.fixture -def seller(currencies): +def seller_factory(currencies): def _seller( external_id: str, # Must be unique in Marketplace name="E2E Test Seller", @@ -44,7 +44,7 @@ def _seller( @pytest.fixture -def account(): +def account_factory(): def _account( name: str = "E2E Test Api Client Vendor", ): @@ -65,7 +65,7 @@ def _account( @pytest.fixture -def buyer(buyer_account_id): +def buyer_factory(buyer_account_id): def _buyer( name="E2E Created Buyer", account_id: str = buyer_account_id, @@ -93,7 +93,7 @@ def _buyer( @pytest.fixture -def user_group(account_id): +def user_group_factory(account_id, module_id): def _user_group( name: str = "E2E Test Api Client User Group", ): @@ -103,7 +103,24 @@ def _user_group( "buyers": None, "logo": "", "description": "User group for E2E tests", - "modules": [{"id": "MOD-1756"}], + "modules": [{"id": module_id}], } return _user_group + + +@pytest.fixture +def api_token_factory(account_id, module_id): + def _api_token( + name: str = "E2E Test API Token", + description: str = "E2E API Token created during E2E tests", + ): + return { + "account": {"id": account_id}, + "name": name, + "description": description, + "icon": "", + "modules": [{"id": module_id}], + } + + return _api_token diff --git a/tests/e2e/accounts/sellers/test_async_sellers.py b/tests/e2e/accounts/sellers/test_async_sellers.py index 5d9e795f..22de5417 100644 --- a/tests/e2e/accounts/sellers/test_async_sellers.py +++ b/tests/e2e/accounts/sellers/test_async_sellers.py @@ -8,7 +8,7 @@ # TODO: Handle create and teardown more gracefully with fixture that doesn't cause teardown issues @pytest.fixture -async def async_created_seller(async_mpt_ops, seller, logger): +async def async_created_seller(async_mpt_ops, seller_factory, logger): ret_seller = None async def _async_created_seller( @@ -16,7 +16,7 @@ async def _async_created_seller( name: str = "E2E Test Seller", ): nonlocal ret_seller # noqa: WPS420 - seller_data = seller(external_id=external_id, name=name) + seller_data = seller_factory(external_id=external_id, name=name) ret_seller = await async_mpt_ops.accounts.sellers.create(seller_data) return ret_seller @@ -76,9 +76,9 @@ async def test_delete_seller_not_found(async_mpt_ops, invalid_seller_id): await async_mpt_ops.accounts.sellers.delete(invalid_seller_id) -async def test_update_seller(async_mpt_ops, seller, async_created_seller, timestamp): +async def test_update_seller(async_mpt_ops, seller_factory, async_created_seller, timestamp): seller_data = await async_created_seller(external_id=f"Async Update E2E Seller - {timestamp}") - update_data = seller( + update_data = seller_factory( external_id=f"Async Update E2E Seller - {timestamp}", name=f"Updated Update E2E Seller - {timestamp}", ) @@ -86,8 +86,8 @@ async def test_update_seller(async_mpt_ops, seller, async_created_seller, timest assert updated_seller is not None -async def test_update_seller_mpt_error(async_mpt_ops, seller, timestamp, invalid_seller_id): - update_data = seller( +async def test_update_seller_mpt_error(async_mpt_ops, seller_factory, timestamp, invalid_seller_id): + update_data = seller_factory( external_id=f"Async Update E2E Seller Not Found - {timestamp}", name=f"Updated Update E2E Seller Not Found - {timestamp}", ) diff --git a/tests/e2e/accounts/sellers/test_sync_sellers.py b/tests/e2e/accounts/sellers/test_sync_sellers.py index 5a07346b..f91b554d 100644 --- a/tests/e2e/accounts/sellers/test_sync_sellers.py +++ b/tests/e2e/accounts/sellers/test_sync_sellers.py @@ -7,7 +7,7 @@ @pytest.fixture -def created_seller(mpt_ops, seller, logger): +def created_seller(mpt_ops, seller_factory, logger): ret_seller = None def _created_seller( @@ -15,7 +15,7 @@ def _created_seller( name: str = "E2E Test Seller", ): nonlocal ret_seller # noqa: WPS420 - seller_data = seller(external_id=external_id, name=name) + seller_data = seller_factory(external_id=external_id, name=name) ret_seller = mpt_ops.accounts.sellers.create(seller_data) return ret_seller @@ -75,9 +75,9 @@ def test_delete_seller_not_found(mpt_ops, invalid_seller_id): mpt_ops.accounts.sellers.delete(invalid_seller_id) -def test_update_seller(mpt_ops, seller, created_seller, timestamp): +def test_update_seller(mpt_ops, seller_factory, created_seller, timestamp): seller_data = created_seller(external_id=f"Update E2E Seller - {timestamp}") - update_data = seller( + update_data = seller_factory( external_id=f"Update E2E Seller - {timestamp}", name=f"Updated Update E2E Seller - {timestamp}", ) @@ -85,8 +85,8 @@ def test_update_seller(mpt_ops, seller, created_seller, timestamp): assert updated_seller is not None -def test_update_seller_mpt_error(mpt_ops, seller, timestamp, invalid_seller_id): - update_data = seller( +def test_update_seller_mpt_error(mpt_ops, seller_factory, timestamp, invalid_seller_id): + update_data = seller_factory( external_id=f"Async Update E2E Seller Not Found - {timestamp}", name=f"Updated Update E2E Seller Not Found - {timestamp}", ) diff --git a/tests/e2e/accounts/user_groups/test_async_user_groups.py b/tests/e2e/accounts/user_groups/test_async_user_groups.py index 25619be9..324070c4 100644 --- a/tests/e2e/accounts/user_groups/test_async_user_groups.py +++ b/tests/e2e/accounts/user_groups/test_async_user_groups.py @@ -7,8 +7,8 @@ @pytest.fixture -async def created_user_group(async_mpt_ops, user_group): - new_user_group_request_data = user_group() +async def created_user_group(async_mpt_ops, user_group_factory): + new_user_group_request_data = user_group_factory() created_user_group = await async_mpt_ops.accounts.user_groups.create( new_user_group_request_data ) @@ -67,8 +67,8 @@ async def test_delete_user_group_not_found(async_mpt_ops, invalid_user_group_id) await async_mpt_ops.accounts.user_groups.delete(invalid_user_group_id) -async def test_update_user_group(async_mpt_ops, user_group, created_user_group): - updated_user_group_data = user_group(name="E2E Updated User Group") +async def test_update_user_group(async_mpt_ops, user_group_factory, created_user_group): + updated_user_group_data = user_group_factory(name="E2E Updated User Group") updated_user_group = await async_mpt_ops.accounts.user_groups.update( created_user_group.id, updated_user_group_data @@ -77,8 +77,10 @@ async def test_update_user_group(async_mpt_ops, user_group, created_user_group): assert updated_user_group is not None -async def test_update_user_group_not_found(async_mpt_ops, user_group, invalid_user_group_id): - updated_user_group_data = user_group(name="Nonexistent User Group") +async def test_update_user_group_not_found( + async_mpt_ops, user_group_factory, invalid_user_group_id +): + updated_user_group_data = user_group_factory(name="Nonexistent User Group") with pytest.raises(MPTAPIError, match=r"404 Not Found"): await async_mpt_ops.accounts.user_groups.update( diff --git a/tests/e2e/accounts/user_groups/test_sync_user_groups.py b/tests/e2e/accounts/user_groups/test_sync_user_groups.py index 67651c6f..bbd3cf45 100644 --- a/tests/e2e/accounts/user_groups/test_sync_user_groups.py +++ b/tests/e2e/accounts/user_groups/test_sync_user_groups.py @@ -7,8 +7,8 @@ @pytest.fixture -def created_user_group(mpt_ops, user_group): - new_user_group_request_data = user_group() +def created_user_group(mpt_ops, user_group_factory): + new_user_group_request_data = user_group_factory() created_user_group = mpt_ops.accounts.user_groups.create(new_user_group_request_data) yield created_user_group @@ -63,8 +63,8 @@ def test_delete_user_group_not_found(mpt_ops, invalid_user_group_id): mpt_ops.accounts.user_groups.delete(invalid_user_group_id) -def test_update_user_group(mpt_ops, user_group, created_user_group): - updated_user_group_data = user_group(name="E2E Updated User Group") +def test_update_user_group(mpt_ops, user_group_factory, created_user_group): + updated_user_group_data = user_group_factory(name="E2E Updated User Group") updated_user_group = mpt_ops.accounts.user_groups.update( created_user_group.id, updated_user_group_data @@ -73,8 +73,8 @@ def test_update_user_group(mpt_ops, user_group, created_user_group): assert updated_user_group is not None -def test_update_user_group_not_found(mpt_ops, user_group, invalid_user_group_id): - updated_user_group_data = user_group(name="Nonexistent User Group") +def test_update_user_group_not_found(mpt_ops, user_group_factory, invalid_user_group_id): + updated_user_group_data = user_group_factory(name="Nonexistent User Group") with pytest.raises(MPTAPIError, match=r"404 Not Found"): mpt_ops.accounts.user_groups.update(invalid_user_group_id, updated_user_group_data) diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index 98c564c3..074b6088 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -155,3 +155,13 @@ def invalid_module_id(): @pytest.fixture def module_name(e2e_config): return e2e_config["accounts.module.name"] + + +@pytest.fixture +def api_token_id(e2e_config): + return e2e_config["accounts.api_token.id"] + + +@pytest.fixture +def invalid_api_token_id(): + return "TKN-0000-0000"