-
Notifications
You must be signed in to change notification settings - Fork 0
MPT-14897 E2E Catalog listings #149
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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}, | ||
| } |
| 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 |
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Remove duplicate fixture definition. The Apply this diff: -@pytest.fixture
-def listings_service(mpt_ops):
- return mpt_ops.catalog.listings
-
-📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
|
|
||||||||
|
|
||||||||
| @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 | ||||||||
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.
Duplicate fixture name creates shadowing and confusion.
This
authorization_idfixture shadows an existing fixture intests/e2e/conftest.py(lines 141-142) that retrievescommerce.authorization.id. While pytest's scoping means this catalog-specific version will take precedence within thetests/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_idvscommerce_authorization_id) to make the distinction explicit and prevent unintended fixture resolution.🤖 Prompt for AI Agents