From c9a22d647009c1bb6fbff84de2cfd0e60bbe9a1f Mon Sep 17 00:00:00 2001 From: Albert Sola Date: Wed, 3 Dec 2025 16:47:42 +0000 Subject: [PATCH] MPT-14897 E2E Catalog listings --- e2e_config.test.json | 19 +++--- tests/e2e/catalog/conftest.py | 10 ++++ tests/e2e/catalog/listings/conftest.py | 29 ++++++++++ .../catalog/listings/test_async_listings.py | 56 ++++++++++++++++++ .../catalog/listings/test_sync_listings.py | 58 +++++++++++++++++++ tests/e2e/conftest.py | 5 ++ 6 files changed, 169 insertions(+), 8 deletions(-) create mode 100644 tests/e2e/catalog/listings/conftest.py create mode 100644 tests/e2e/catalog/listings/test_async_listings.py create mode 100644 tests/e2e/catalog/listings/test_sync_listings.py diff --git a/e2e_config.test.json b/e2e_config.test.json index c04a14b1..df6a5215 100644 --- a/e2e_config.test.json +++ b/e2e_config.test.json @@ -11,16 +11,12 @@ "accounts.seller.id": "SEL-7310-3075", "accounts.user.id": "USR-9673-3314", "accounts.user_group.id": "UGR-6822-0561", - "commerce.agreement.id": "AGR-9850-2169-6098", - "commerce.product.id": "PRD-1767-7355", - "commerce.product.item.id": "ITM-1767-7355-0001", - "commerce.product.listing.id": "LST-5489-0806", - "commerce.product.template.id": "TPL-1767-7355-0003", - "commerce.authorization.id": "AUT-0031-2873", - "commerce.client.id": "ACC-1086-6867", - "catalog.product.item.id": "ITM-7255-3950-0751", + "catalog.authorization.id": "AUT-9288-6146", + "catalog.listing.id": "LST-5489-0806", "catalog.product.document.id": "PDC-7255-3950-0001", + "catalog.price_list.id": "PRC-7255-3950-0245", "catalog.product.id": "PRD-7255-3950", + "catalog.product.item.id": "ITM-7255-3950-0751", "catalog.product.item_group.id": "IGR-7255-3950-0001", "catalog.product.parameter.id": "PAR-7255-3950-0016", "catalog.product.parameter_group.id": "PGR-7255-3950-0001", @@ -28,5 +24,12 @@ "catalog.product.terms.id": "TCS-7255-3950-0001", "catalog.product.terms.variant.id": "TCV-7255-3950-0001-0001", "catalog.unit.id": "UNT-1229", + "commerce.agreement.id": "AGR-9850-2169-6098", + "commerce.authorization.id": "AUT-0031-2873", + "commerce.client.id": "ACC-1086-6867", + "commerce.product.id": "PRD-1767-7355", + "commerce.product.item.id": "ITM-1767-7355-0001", + "commerce.product.listing.id": "LST-5489-0806", + "commerce.product.template.id": "TPL-1767-7355-0003", "notifications.message.id": "MSG-0000-6215-1019-0139" } diff --git a/tests/e2e/catalog/conftest.py b/tests/e2e/catalog/conftest.py index 17facc11..c5765bce 100644 --- a/tests/e2e/catalog/conftest.py +++ b/tests/e2e/catalog/conftest.py @@ -14,3 +14,13 @@ def item_group_id(e2e_config): @pytest.fixture def unit_id(e2e_config): return e2e_config.get("catalog.unit.id") + + +@pytest.fixture +def authorization_id(e2e_config): + return e2e_config["catalog.authorization.id"] + + +@pytest.fixture +def price_list_id(e2e_config): + return e2e_config["catalog.price_list.id"] diff --git a/tests/e2e/catalog/listings/conftest.py b/tests/e2e/catalog/listings/conftest.py new file mode 100644 index 00000000..7c86748f --- /dev/null +++ b/tests/e2e/catalog/listings/conftest.py @@ -0,0 +1,29 @@ +import pytest + + +@pytest.fixture +def listing_id(e2e_config): + return e2e_config["catalog.listing.id"] + + +@pytest.fixture +def listing_data(authorization_id, product_id, account_id, seller_id, price_list_id): + return { + "name": "e2e - please delete", + "authorization": { + "id": authorization_id, + }, + "product": { + "id": product_id, + }, + "vendor": { + "id": account_id, + }, + "seller": { + "id": seller_id, + }, + "priceList": {"id": price_list_id}, + "primary": False, + "notes": "", + "eligibility": {"client": True, "partner": False}, + } diff --git a/tests/e2e/catalog/listings/test_async_listings.py b/tests/e2e/catalog/listings/test_async_listings.py new file mode 100644 index 00000000..d33de683 --- /dev/null +++ b/tests/e2e/catalog/listings/test_async_listings.py @@ -0,0 +1,56 @@ +import pytest + +from mpt_api_client.exceptions import MPTAPIError +from tests.e2e.helper import ( + assert_async_service_filter_with_iterate, + assert_async_update_resource, + async_create_fixture_resource_and_delete, +) + +pytestmark = [pytest.mark.flaky] + + +@pytest.fixture +def async_listings_service(async_mpt_ops): + return async_mpt_ops.catalog.listings + + +@pytest.fixture +async def async_created_listing(async_listings_service, listing_data): + async with async_create_fixture_resource_and_delete( + async_listings_service, listing_data + ) as listing: + yield listing + + +def test_create_listing(async_created_listing, product_id): + result = async_created_listing.product.id + + assert result == product_id + + +async def test_get_listing(async_listings_service, listing_id): + result = await async_listings_service.get(listing_id) + + assert result.id == listing_id + + +async def test_filter_listings(async_listings_service, listing_id): + await assert_async_service_filter_with_iterate(async_listings_service, listing_id, None) # act + + +async def test_get_listing_not_found(async_listings_service): + bogus_id = "LST-0000-NOTFOUND" + + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + await async_listings_service.get(bogus_id) + + +async def test_update_listing(async_listings_service, async_created_listing, short_uuid): + await assert_async_update_resource( + async_listings_service, async_created_listing.id, "notes", f"delete-me {short_uuid}" + ) # act + + +async def test_delete_listing(async_listings_service, async_created_listing): + await async_listings_service.delete(async_created_listing.id) # act diff --git a/tests/e2e/catalog/listings/test_sync_listings.py b/tests/e2e/catalog/listings/test_sync_listings.py new file mode 100644 index 00000000..6e2d784f --- /dev/null +++ b/tests/e2e/catalog/listings/test_sync_listings.py @@ -0,0 +1,58 @@ +import pytest + +from mpt_api_client.exceptions import MPTAPIError +from tests.e2e.helper import ( + assert_service_filter_with_iterate, + assert_update_resource, + create_fixture_resource_and_delete, +) + +pytestmark = [pytest.mark.flaky] + + +@pytest.fixture +def listings_service(mpt_ops): + return mpt_ops.catalog.listings + + +@pytest.fixture +def created_listing(listings_service, listing_data): + with create_fixture_resource_and_delete(listings_service, listing_data) as listing: + yield listing + + +def test_create_listing(created_listing, product_id): + result = created_listing.product.id + + assert result == product_id + + +def test_get_listing_by_id(listings_service, listing_id): + result = listings_service.get(listing_id) + + assert result.id == listing_id + + +def test_filter_listings(listings_service, listing_id): + assert_service_filter_with_iterate( + listings_service, + listing_id, + None, + ) # act + + +def test_get_listing_not_found(listings_service): + bogus_id = "LST-0000-NOTFOUND" + + with pytest.raises(MPTAPIError, match=r"404 Not Found"): + listings_service.get(bogus_id) + + +def test_update_listing(listings_service, created_listing, short_uuid): + assert_update_resource( + listings_service, created_listing.id, "notes", f"delete-me {short_uuid}" + ) # act + + +def test_delete_listing(listings_service, created_listing): + listings_service.delete(created_listing.id) # act diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index 86b6efed..14985b58 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -146,3 +146,8 @@ def licensee_id(e2e_config): @pytest.fixture def authorization_id(e2e_config): return e2e_config["commerce.authorization.id"] + + +@pytest.fixture +def price_list_id(e2e_config): + return e2e_config["catalog.price_list.id"]