From 3eeb55869a5aa7e0d00f52c7f31ce8b02cfb9c3f Mon Sep 17 00:00:00 2001 From: Albert Sola Date: Fri, 21 Nov 2025 12:13:12 +0000 Subject: [PATCH] MPT-14891 E2E for product terms and variants --- e2e_config.test.json | 2 + mpt_api_client/resources/catalog/mixins.py | 23 +--- .../catalog/product_term_variants.py | 16 ++- .../resources/catalog/product_terms.py | 4 +- .../resources/catalog/products_documents.py | 2 + .../resources/catalog/products_media.py | 2 + .../e2e/catalog/product/documents/conftest.py | 1 + .../product/documents/test_async_document.py | 2 +- .../product/documents/test_sync_document.py | 8 +- .../catalog/product/media/test_async_media.py | 2 +- tests/e2e/catalog/product/terms/conftest.py | 11 ++ .../catalog/product/terms/test_async_terms.py | 67 +++++++++++ .../catalog/product/terms/test_sync_terms.py | 79 +++++++++++++ .../product/terms/variants/conftest.py | 17 +++ .../terms/variants/test_async_variants.py | 104 ++++++++++++++++++ .../terms/variants/test_sync_variants.py | 78 +++++++++++++ tests/unit/resources/catalog/test_mixins.py | 4 + .../catalog/test_product_term_variants.py | 14 ++- .../resources/catalog/test_product_terms.py | 4 +- 19 files changed, 402 insertions(+), 38 deletions(-) create mode 100644 tests/e2e/catalog/product/terms/conftest.py create mode 100644 tests/e2e/catalog/product/terms/test_async_terms.py create mode 100644 tests/e2e/catalog/product/terms/test_sync_terms.py create mode 100644 tests/e2e/catalog/product/terms/variants/conftest.py create mode 100644 tests/e2e/catalog/product/terms/variants/test_async_variants.py create mode 100644 tests/e2e/catalog/product/terms/variants/test_sync_variants.py diff --git a/e2e_config.test.json b/e2e_config.test.json index 3080ff22..d19b362c 100644 --- a/e2e_config.test.json +++ b/e2e_config.test.json @@ -17,5 +17,7 @@ "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" } diff --git a/mpt_api_client/resources/catalog/mixins.py b/mpt_api_client/resources/catalog/mixins.py index 6eb9e53f..ca8593cc 100644 --- a/mpt_api_client/resources/catalog/mixins.py +++ b/mpt_api_client/resources/catalog/mixins.py @@ -84,9 +84,6 @@ async def unpublish(self, resource_id: str, resource_data: ResourceData | None = class AsyncCreateFileMixin[Model]: """Create file mixin.""" - _upload_file_key = "file" - _upload_data_key = "document" - async def create(self, resource_data: ResourceData, file: FileTypes | None = None) -> Model: """Create document. @@ -101,13 +98,13 @@ async def create(self, resource_data: ResourceData, file: FileTypes | None = Non """ files = {} if file: - files[self._upload_file_key] = file + files[self._upload_file_key] = file # type: ignore[attr-defined] response = await self.http_client.request( # type: ignore[attr-defined] "post", self.path, # type: ignore[attr-defined] json=resource_data, files=files, - json_file_key=self._upload_data_key, + json_file_key=self._upload_data_key, # type: ignore[attr-defined] force_multipart=True, ) return self._model_class.from_response(response) # type: ignore[attr-defined, no-any-return] @@ -124,9 +121,6 @@ class AsyncDocumentMixin[Model]( class CreateFileMixin[Model]: """Create file mixin.""" - _upload_file_key = "file" - _upload_data_key = "document" - def create(self, resource_data: ResourceData, file: FileTypes | None = None) -> Model: """Create document. @@ -141,13 +135,13 @@ def create(self, resource_data: ResourceData, file: FileTypes | None = None) -> """ files = {} if file: - files[self._upload_file_key] = file + files[self._upload_file_key] = file # type: ignore[attr-defined] response = self.http_client.request( # type: ignore[attr-defined] "post", self.path, # type: ignore[attr-defined] json=resource_data, files=files, - json_file_key=self._upload_data_key, + json_file_key=self._upload_data_key, # type: ignore[attr-defined] force_multipart=True, ) return self._model_class.from_response(response) # type: ignore[attr-defined, no-any-return] @@ -160,9 +154,6 @@ class DocumentMixin[Model]( ): """Document mixin.""" - _upload_file_key = "file" - _upload_data_key = "document" - class MediaMixin[Model]( CreateFileMixin[Model], @@ -171,9 +162,6 @@ class MediaMixin[Model]( ): """Media mixin.""" - _upload_file_key = "file" - _upload_data_key = "media" - class ActivatableMixin[Model]: """Activatable mixin adds the ability to activate and deactivate.""" @@ -235,6 +223,3 @@ class AsyncMediaMixin[Model]( AsyncPublishableMixin[Model], ): """Media mixin.""" - - _upload_file_key = "file" - _upload_data_key = "media" diff --git a/mpt_api_client/resources/catalog/product_term_variants.py b/mpt_api_client/resources/catalog/product_term_variants.py index 2edae1ab..826e4ce9 100644 --- a/mpt_api_client/resources/catalog/product_term_variants.py +++ b/mpt_api_client/resources/catalog/product_term_variants.py @@ -1,15 +1,17 @@ from mpt_api_client.http import AsyncService, Service from mpt_api_client.http.mixins import ( AsyncCollectionMixin, - AsyncFilesOperationsMixin, + AsyncDownloadFileMixin, AsyncModifiableResourceMixin, CollectionMixin, - FilesOperationsMixin, + DownloadFileMixin, ModifiableResourceMixin, ) from mpt_api_client.models import Model from mpt_api_client.resources.catalog.mixins import ( + AsyncCreateFileMixin, AsyncPublishableMixin, + CreateFileMixin, PublishableMixin, ) @@ -21,13 +23,16 @@ class TermVariant(Model): class TermVariantServiceConfig: """Term variant service configuration.""" - _endpoint = "/public/v1/catalog/products/terms/{term_id}/variants" + _endpoint = "/public/v1/catalog/products/{product_id}/terms/{term_id}/variants" _model_class = TermVariant _collection_key = "data" + _upload_file_key = "file" + _upload_data_key = "variant" class TermVariantService( - FilesOperationsMixin[TermVariant], + CreateFileMixin[TermVariant], + DownloadFileMixin[TermVariant], ModifiableResourceMixin[TermVariant], PublishableMixin[TermVariant], CollectionMixin[TermVariant], @@ -38,7 +43,8 @@ class TermVariantService( class AsyncTermVariantService( - AsyncFilesOperationsMixin[TermVariant], + AsyncCreateFileMixin[TermVariant], + AsyncDownloadFileMixin[TermVariant], AsyncModifiableResourceMixin[TermVariant], AsyncPublishableMixin[TermVariant], AsyncCollectionMixin[TermVariant], diff --git a/mpt_api_client/resources/catalog/product_terms.py b/mpt_api_client/resources/catalog/product_terms.py index a443885a..9afd7b5a 100644 --- a/mpt_api_client/resources/catalog/product_terms.py +++ b/mpt_api_client/resources/catalog/product_terms.py @@ -38,7 +38,7 @@ def variants(self, term_id: str) -> TermVariantService: """Access term variants service.""" return TermVariantService( http_client=self.http_client, - endpoint_params={"term_id": term_id}, + endpoint_params={"product_id": self.endpoint_params["product_id"], "term_id": term_id}, ) @@ -55,5 +55,5 @@ def variants(self, term_id: str) -> AsyncTermVariantService: """Access async term variants service.""" return AsyncTermVariantService( http_client=self.http_client, - endpoint_params={"term_id": term_id}, + endpoint_params={"product_id": self.endpoint_params["product_id"], "term_id": term_id}, ) diff --git a/mpt_api_client/resources/catalog/products_documents.py b/mpt_api_client/resources/catalog/products_documents.py index 01ce52c2..c0f59bae 100644 --- a/mpt_api_client/resources/catalog/products_documents.py +++ b/mpt_api_client/resources/catalog/products_documents.py @@ -22,6 +22,8 @@ class DocumentServiceConfig: _endpoint = "/public/v1/catalog/products/{product_id}/documents" _model_class = Document _collection_key = "data" + _upload_file_key = "file" + _upload_data_key = "document" class DocumentService( diff --git a/mpt_api_client/resources/catalog/products_media.py b/mpt_api_client/resources/catalog/products_media.py index 6665836b..767add5d 100644 --- a/mpt_api_client/resources/catalog/products_media.py +++ b/mpt_api_client/resources/catalog/products_media.py @@ -22,6 +22,8 @@ class MediaServiceConfig: _endpoint = "/public/v1/catalog/products/{product_id}/media" _model_class = Media _collection_key = "data" + _upload_file_key = "file" + _upload_data_key = "media" class MediaService( diff --git a/tests/e2e/catalog/product/documents/conftest.py b/tests/e2e/catalog/product/documents/conftest.py index f4badb30..ce29b6c2 100644 --- a/tests/e2e/catalog/product/documents/conftest.py +++ b/tests/e2e/catalog/product/documents/conftest.py @@ -12,6 +12,7 @@ def document_data(): "name": "e2e test document - please delete", "description": "E2E test document for automated testing", "language": "en-gb", + "url": "", } diff --git a/tests/e2e/catalog/product/documents/test_async_document.py b/tests/e2e/catalog/product/documents/test_async_document.py index 30fff07f..e923bb00 100644 --- a/tests/e2e/catalog/product/documents/test_async_document.py +++ b/tests/e2e/catalog/product/documents/test_async_document.py @@ -3,7 +3,7 @@ from mpt_api_client.exceptions import MPTAPIError from mpt_api_client.rql.query_builder import RQLQuery -pytestmark = [pytest.mark.flaky, pytest.mark.asyncio] +pytestmark = [pytest.mark.flaky] @pytest.fixture diff --git a/tests/e2e/catalog/product/documents/test_sync_document.py b/tests/e2e/catalog/product/documents/test_sync_document.py index 828a8994..0e2da5f2 100644 --- a/tests/e2e/catalog/product/documents/test_sync_document.py +++ b/tests/e2e/catalog/product/documents/test_sync_document.py @@ -18,7 +18,7 @@ def created_document_from_file(logger, vendor_document_service, document_data, p @pytest.fixture -def created_document_from_link(logger, vendor_document_service, document_data, pdf_url): +def created_document_from_url(logger, vendor_document_service, document_data, pdf_url): document_data["url"] = pdf_url document = vendor_document_service.create(document_data) yield document @@ -33,9 +33,9 @@ def test_create_document(created_document_from_file, document_data): assert created_document_from_file.description == document_data["description"] -def test_create_from_link(created_document_from_link, pdf_url, document_data): - assert created_document_from_link.name == document_data["name"] - assert created_document_from_link.description == document_data["description"] +def test_create_document_from_url(created_document_from_url, document_data): + assert created_document_from_url.name == document_data["name"] + assert created_document_from_url.description == document_data["description"] def test_update_document(vendor_document_service, created_document_from_file): diff --git a/tests/e2e/catalog/product/media/test_async_media.py b/tests/e2e/catalog/product/media/test_async_media.py index d865f523..41a1ae0f 100644 --- a/tests/e2e/catalog/product/media/test_async_media.py +++ b/tests/e2e/catalog/product/media/test_async_media.py @@ -2,7 +2,7 @@ from mpt_api_client.exceptions import MPTAPIError -pytestmark = [pytest.mark.flaky, pytest.mark.asyncio] +pytestmark = [pytest.mark.flaky] @pytest.fixture diff --git a/tests/e2e/catalog/product/terms/conftest.py b/tests/e2e/catalog/product/terms/conftest.py new file mode 100644 index 00000000..b2662a72 --- /dev/null +++ b/tests/e2e/catalog/product/terms/conftest.py @@ -0,0 +1,11 @@ +import pytest + + +@pytest.fixture +def term_data(): + return {"name": "e2e - please delete", "description": "Test term description"} + + +@pytest.fixture +def term_id(e2e_config): + return e2e_config["catalog.product.terms.id"] diff --git a/tests/e2e/catalog/product/terms/test_async_terms.py b/tests/e2e/catalog/product/terms/test_async_terms.py new file mode 100644 index 00000000..2a68edc3 --- /dev/null +++ b/tests/e2e/catalog/product/terms/test_async_terms.py @@ -0,0 +1,67 @@ +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 async_vendor_terms_service(async_mpt_vendor, product_id): + return async_mpt_vendor.catalog.products.terms(product_id) + + +@pytest.fixture +async def async_created_term(async_vendor_terms_service, term_data): + service = async_vendor_terms_service + term = await service.create(term_data) + yield term + try: + await service.delete(term.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete term {term.id}: {error.title}") + + +def test_create_term(async_created_term): + term = async_created_term + assert term.name == "e2e - please delete" + + +async def test_update_term(async_vendor_terms_service, async_created_term): + service = async_vendor_terms_service + update_data = {"name": "e2e - delete me (updated)"} + term = await service.update(async_created_term.id, update_data) + assert term.name == "e2e - delete me (updated)" + + +async def test_get_term(async_vendor_terms_service, term_id): + service = async_vendor_terms_service + term = await service.get(term_id) + assert term.id == term_id + + +async def test_get_term_by_id(async_vendor_terms_service, term_id): + service = async_vendor_terms_service + term = await service.get(term_id) + assert term.id == term_id + + +async def test_iterate_terms(async_vendor_terms_service, async_created_term): + service = async_vendor_terms_service + terms = [term async for term in service.iterate()] + assert any(term.id == async_created_term.id for term in terms) + + +async def test_filter_terms(async_vendor_terms_service, term_id): + select_fields = ["-description"] + filtered_terms = async_vendor_terms_service.filter(RQLQuery(id=term_id)).select(*select_fields) + terms = [term async for term in filtered_terms.iterate()] + assert len(terms) == 1 + assert terms[0].id == term_id + + +async def test_delete_term(async_vendor_terms_service, async_created_term): + service = async_vendor_terms_service + await service.delete(async_created_term.id) + with pytest.raises(MPTAPIError): + await service.get(async_created_term.id) diff --git a/tests/e2e/catalog/product/terms/test_sync_terms.py b/tests/e2e/catalog/product/terms/test_sync_terms.py new file mode 100644 index 00000000..462a579d --- /dev/null +++ b/tests/e2e/catalog/product/terms/test_sync_terms.py @@ -0,0 +1,79 @@ +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 vendor_terms_service(mpt_vendor, product_id): + return mpt_vendor.catalog.products.terms(product_id) + + +@pytest.fixture +def created_term(logger, vendor_terms_service, term_data): + service = vendor_terms_service + term = service.create(term_data) + yield term + try: + service.delete(term.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete term {term.id}: {error.title}") + + +@pytest.fixture +def created_term_from_url(logger, vendor_terms_service, term_data, pdf_url): + term_data["url"] = pdf_url + service = vendor_terms_service + term = service.create(term_data) + yield term + try: + service.delete(term.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete term {term.id}: {error.title}") + + +def test_create_term(created_term): + term = created_term + assert term.name == "e2e - please delete" + + +def test_update_term(vendor_terms_service, created_term): + service = vendor_terms_service + update_data = {"name": "e2e - delete me (updated)"} + term = service.update(created_term.id, update_data) + assert term.name == "e2e - delete me (updated)" + + +def test_get_term(vendor_terms_service, term_id): + service = vendor_terms_service + term = service.get(term_id) + assert term.id == term_id + + +def test_get_term_by_id(vendor_terms_service, term_id): + service = vendor_terms_service + term = service.get(term_id) + assert term.id == term_id + + +def test_iterate_terms(vendor_terms_service, created_term): + service = vendor_terms_service + terms = list(service.iterate()) + assert any(term.id == created_term.id for term in terms) + + +def test_filter_terms(vendor_terms_service, term_id): + select_fields = ["-description"] + filtered_terms = vendor_terms_service.filter(RQLQuery(id=term_id)).select(*select_fields) + terms = list(filtered_terms.iterate()) + assert len(terms) == 1 + assert terms[0].id == term_id + + +def test_delete_term(vendor_terms_service, created_term): + service = vendor_terms_service + service.delete(created_term.id) + with pytest.raises(MPTAPIError): + service.get(created_term.id) diff --git a/tests/e2e/catalog/product/terms/variants/conftest.py b/tests/e2e/catalog/product/terms/variants/conftest.py new file mode 100644 index 00000000..6049d6d4 --- /dev/null +++ b/tests/e2e/catalog/product/terms/variants/conftest.py @@ -0,0 +1,17 @@ +import pytest + + +@pytest.fixture +def variant_data(): + return { + "name": "e2e - please delete", + "description": "Test variant description", + "languageCode": "en-gb", + "type": "File", + "assetUrl": "", + } + + +@pytest.fixture +def variant_id(e2e_config): + return e2e_config["catalog.product.terms.variant.id"] diff --git a/tests/e2e/catalog/product/terms/variants/test_async_variants.py b/tests/e2e/catalog/product/terms/variants/test_async_variants.py new file mode 100644 index 00000000..2d807f74 --- /dev/null +++ b/tests/e2e/catalog/product/terms/variants/test_async_variants.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 async_vendor_variant_service(async_mpt_vendor, product_id, term_id): + return async_mpt_vendor.catalog.products.terms(product_id).variants(term_id) + + +@pytest.fixture +async def async_created_variant( + variant_data, + pdf_fd, + async_vendor_variant_service, +): + variant = await async_vendor_variant_service.create(variant_data, pdf_fd) + yield variant + try: + await async_vendor_variant_service.delete(variant.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete variant {variant.id}: {error.title}") + + +@pytest.fixture +async def created_variant_from_url( + variant_data, + pdf_url, + async_vendor_variant_service, +): + variant_data["type"] = "Online" + variant_data["assetUrl"] = pdf_url + variant = await async_vendor_variant_service.create(variant_data) + yield variant + try: + await async_vendor_variant_service.delete(variant.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete variant {variant.id}: {error.title}") + + +def test_create_variant(async_created_variant): + variant = async_created_variant + assert variant.name == "e2e - please delete" + + +def test_create_variant_from_url(created_variant_from_url, variant_data): + assert created_variant_from_url.name == variant_data["name"] + + +async def test_update_variant( + async_mpt_vendor, product_id, term_id, async_created_variant, async_vendor_variant_service +): + service = async_vendor_variant_service + update_data = {"name": "e2e - delete me (updated)"} + variant = await service.update(async_created_variant.id, update_data) + assert variant.name == "e2e - delete me (updated)" + + +async def test_get_variant( + async_mpt_vendor, product_id, term_id, variant_id, async_vendor_variant_service +): + service = async_vendor_variant_service + variant = await service.get(variant_id) + assert variant.id == variant_id + + +async def test_get_variant_by_id( + async_mpt_vendor, product_id, term_id, variant_id, async_vendor_variant_service +): + service = async_vendor_variant_service + variant = await service.get(variant_id) + assert variant.id == variant_id + + +async def test_iterate_variants( + async_mpt_vendor, product_id, term_id, async_created_variant, async_vendor_variant_service +): + service = async_vendor_variant_service + variants = [variant async for variant in service.iterate()] + assert any(variant.id == async_created_variant.id for variant in variants) + + +async def test_filter_variants( + async_mpt_vendor, product_id, term_id, variant_id, async_vendor_variant_service +): + select_fields = ["-description"] + filtered_variants = async_vendor_variant_service.filter(RQLQuery(id=variant_id)).select( + *select_fields + ) + variants = [variant async for variant in filtered_variants.iterate()] + assert len(variants) == 1 + assert variants[0].id == variant_id + + +async def test_delete_variant( + async_mpt_vendor, product_id, term_id, async_created_variant, async_vendor_variant_service +): + service = async_vendor_variant_service + await service.delete(async_created_variant.id) + with pytest.raises(MPTAPIError): + await service.get(async_created_variant.id) diff --git a/tests/e2e/catalog/product/terms/variants/test_sync_variants.py b/tests/e2e/catalog/product/terms/variants/test_sync_variants.py new file mode 100644 index 00000000..4833125a --- /dev/null +++ b/tests/e2e/catalog/product/terms/variants/test_sync_variants.py @@ -0,0 +1,78 @@ +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 vendor_variant_service(mpt_vendor, product_id, term_id): + return mpt_vendor.catalog.products.terms(product_id).variants(term_id) + + +@pytest.fixture +def created_variant(logger, vendor_variant_service, variant_data, pdf_fd): + variant = vendor_variant_service.create(variant_data, pdf_fd) + yield variant + try: + vendor_variant_service.delete(variant.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete variant {variant.id}: {error.title}") + + +@pytest.fixture +def created_variant_from_url(logger, vendor_variant_service, variant_data, pdf_url): + variant_data["type"] = "Online" + variant_data["assetUrl"] = pdf_url + variant = vendor_variant_service.create(variant_data) + yield variant + try: + vendor_variant_service.delete(variant.id) + except MPTAPIError as error: + print(f"TEARDOWN - Unable to delete variant {variant.id}: {error.title}") + + +def test_create_variant(created_variant, variant_data): + assert created_variant.name == variant_data["name"] + + +def test_create_variant_from_url(created_variant_from_url, variant_data): + assert created_variant_from_url.name == variant_data["name"] + + +def test_update_variant(vendor_variant_service, created_variant): + update_data = {"name": "e2e - delete me (updated)"} + variant = vendor_variant_service.update(created_variant.id, update_data) + assert variant.name == "e2e - delete me (updated)" + + +def test_get_variant(vendor_variant_service, variant_id): + variant = vendor_variant_service.get(variant_id) + assert variant.id == variant_id + + +def test_get_variant_by_id(vendor_variant_service, variant_id): + variant = vendor_variant_service.get(variant_id) + assert variant.id == variant_id + + +def test_iterate_variants(vendor_variant_service, created_variant): + variants = list(vendor_variant_service.iterate()) + assert any(variant.id == created_variant.id for variant in variants) + + +def test_filter_variants(vendor_variant_service, variant_id): + select_fields = ["-description"] + filtered_variants = vendor_variant_service.filter(RQLQuery(id=variant_id)).select( + *select_fields + ) + variants = list(filtered_variants.iterate()) + assert len(variants) == 1 + assert variants[0].id == variant_id + + +def test_delete_variant(vendor_variant_service, created_variant): + vendor_variant_service.delete(created_variant.id) + with pytest.raises(MPTAPIError): + vendor_variant_service.get(created_variant.id) diff --git a/tests/unit/resources/catalog/test_mixins.py b/tests/unit/resources/catalog/test_mixins.py index d015d554..8790c063 100644 --- a/tests/unit/resources/catalog/test_mixins.py +++ b/tests/unit/resources/catalog/test_mixins.py @@ -60,6 +60,8 @@ class DummyDocumentService( # noqa: WPS215 _endpoint = "/public/v1/dummy/documents" _model_class = DummyModel _collection_key = "data" + _upload_file_key = "file" + _upload_data_key = "document" class DummyAsyncDocumentService( # noqa: WPS215 @@ -69,6 +71,8 @@ class DummyAsyncDocumentService( # noqa: WPS215 _endpoint = "/public/v1/dummy/documents" _model_class = DummyModel _collection_key = "data" + _upload_file_key = "file" + _upload_data_key = "document" @pytest.fixture diff --git a/tests/unit/resources/catalog/test_product_term_variants.py b/tests/unit/resources/catalog/test_product_term_variants.py index 45a535ee..429d7a54 100644 --- a/tests/unit/resources/catalog/test_product_term_variants.py +++ b/tests/unit/resources/catalog/test_product_term_variants.py @@ -10,22 +10,28 @@ @pytest.fixture def term_variant_service(http_client: Any) -> TermVariantService: - return TermVariantService(http_client=http_client, endpoint_params={"term_id": "TRM-001"}) + return TermVariantService( + http_client=http_client, endpoint_params={"product_id": "PRD-001", "term_id": "TRM-001"} + ) @pytest.fixture def async_term_variant_service(async_http_client: Any) -> AsyncTermVariantService: return AsyncTermVariantService( - http_client=async_http_client, endpoint_params={"term_id": "TRM-001"} + http_client=async_http_client, + endpoint_params={"product_id": "PRD-001", "term_id": "TRM-001"}, ) def test_endpoint(term_variant_service: TermVariantService) -> None: - assert term_variant_service.path == "/public/v1/catalog/products/terms/TRM-001/variants" + assert term_variant_service.path == "/public/v1/catalog/products/PRD-001/terms/TRM-001/variants" def test_async_endpoint(async_term_variant_service: AsyncTermVariantService) -> None: - assert async_term_variant_service.path == "/public/v1/catalog/products/terms/TRM-001/variants" + assert ( + async_term_variant_service.path + == "/public/v1/catalog/products/PRD-001/terms/TRM-001/variants" + ) @pytest.mark.parametrize( diff --git a/tests/unit/resources/catalog/test_product_terms.py b/tests/unit/resources/catalog/test_product_terms.py index 71ed909e..57d5c419 100644 --- a/tests/unit/resources/catalog/test_product_terms.py +++ b/tests/unit/resources/catalog/test_product_terms.py @@ -51,7 +51,7 @@ def test_variants_property(term_service: TermService) -> None: variants = term_service.variants("TCS-001") assert isinstance(variants, TermVariantService) assert variants.http_client == term_service.http_client - assert variants.endpoint_params == {"term_id": "TCS-001"} + assert variants.endpoint_params == {"product_id": "PRD-001", "term_id": "TCS-001"} def test_async_variants_property(async_term_service: AsyncTermService) -> None: @@ -59,4 +59,4 @@ def test_async_variants_property(async_term_service: AsyncTermService) -> None: variants = async_term_service.variants("TCS-001") assert isinstance(variants, AsyncTermVariantService) assert variants.http_client == async_term_service.http_client - assert variants.endpoint_params == {"term_id": "TCS-001"} + assert variants.endpoint_params == {"product_id": "PRD-001", "term_id": "TCS-001"}