Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions e2e_config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@
"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",
"catalog.product.template.id": "TPL-7255-3950-0001",
"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"
}
10 changes: 10 additions & 0 deletions tests/e2e/catalog/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Comment on lines +19 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Duplicate fixture name creates shadowing and confusion.

This authorization_id fixture shadows an existing fixture in tests/e2e/conftest.py (lines 141-142) that retrieves commerce.authorization.id. While pytest's scoping means this catalog-specific version will take precedence within the tests/e2e/catalog/ directory, having two fixtures with the same name retrieving different configuration keys is confusing and error-prone.

Consider renaming one of these fixtures (e.g., catalog_authorization_id vs commerce_authorization_id) to make the distinction explicit and prevent unintended fixture resolution.

🤖 Prompt for AI Agents
In tests/e2e/catalog/conftest.py around lines 19-21, the fixture
authorization_id duplicates a fixture name defined in tests/e2e/conftest.py and
causes shadowing; rename this fixture to something explicit (e.g.,
catalog_authorization_id), update its return to still use
e2e_config["catalog.authorization.id"], and then update all tests in
tests/e2e/catalog/ that currently depend on authorization_id to use
catalog_authorization_id so resolution is unambiguous and self-documenting.



@pytest.fixture
def price_list_id(e2e_config):
return e2e_config["catalog.price_list.id"]
29 changes: 29 additions & 0 deletions tests/e2e/catalog/listings/conftest.py
Original file line number Diff line number Diff line change
@@ -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},
}
56 changes: 56 additions & 0 deletions tests/e2e/catalog/listings/test_async_listings.py
Original file line number Diff line number Diff line change
@@ -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
58 changes: 58 additions & 0 deletions tests/e2e/catalog/listings/test_sync_listings.py
Original file line number Diff line number Diff line change
@@ -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
Comment on lines +13 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Remove duplicate fixture definition.

The listings_service fixture is already defined in tests/e2e/catalog/listings/conftest.py (lines 4-6). This duplicate definition should be removed.

Apply this diff:

-@pytest.fixture
-def listings_service(mpt_ops):
-    return mpt_ops.catalog.listings
-
-
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@pytest.fixture
def listings_service(mpt_ops):
return mpt_ops.catalog.listings
🤖 Prompt for AI Agents
In tests/e2e/catalog/listings/test_sync_listings.py around lines 13 to 15,
remove the duplicate listings_service fixture definition (it is already defined
in tests/e2e/catalog/listings/conftest.py lines 4-6); delete these three lines
so the test uses the shared fixture from conftest.py instead of redefining it
locally.



@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
5 changes: 5 additions & 0 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]