From 55422e5955300e41e4a1ec7a3d7b9351439be4fd Mon Sep 17 00:00:00 2001 From: Tim Savage Date: Tue, 3 Oct 2023 18:32:58 +1100 Subject: [PATCH] Finish renaming from category to catalogue --- oscar_odin/mappings/catalogue.py | 20 ++++++++++---------- tests/mappings/test_catalogue.py | 10 +++++----- tests/resources/test_catalogue.py | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/oscar_odin/mappings/catalogue.py b/oscar_odin/mappings/catalogue.py index 1c31e84..b01644b 100644 --- a/oscar_odin/mappings/catalogue.py +++ b/oscar_odin/mappings/catalogue.py @@ -11,7 +11,7 @@ from oscar.core.loading import get_class, get_model from .. import resources -from ..resources.category import Structure +from ..resources.catalogue import Structure from ._common import map_queryset __all__ = ( @@ -34,7 +34,7 @@ class ProductImageToResource(odin.Mapping): """Map from an image model to a resource.""" from_obj = ProductImageModel - to_obj = resources.category.Image + to_obj = resources.catalogue.Image @odin.map_field def original(self, value: ImageFieldFile) -> str: @@ -44,10 +44,10 @@ def original(self, value: ImageFieldFile) -> str: class CategoryToResource(odin.Mapping): - """Map from a category model to a resource.""" + """Map from a catalogue model to a resource.""" from_obj = CategoryModel - to_obj = resources.category.Category + to_obj = resources.catalogue.Category @odin.assign_field def meta_title(self) -> str: @@ -66,14 +66,14 @@ class ProductClassToResource(odin.Mapping): """Map from a product class model to a resource.""" from_obj = ProductClassModel - to_obj = resources.category.ProductClass + to_obj = resources.catalogue.ProductClass class ProductToResource(odin.Mapping): """Map from a product model to a resource.""" from_obj = ProductModel - to_obj = resources.category.Product + to_obj = resources.catalogue.Product @odin.map_field def structure(self, value: str) -> Structure: @@ -91,7 +91,7 @@ def meta_title(self) -> str: return self.source.get_meta_title() @odin.assign_field(to_list=True) - def images(self) -> List[resources.category.Image]: + def images(self) -> List[resources.catalogue.Image]: """Map related image.""" items = self.source.get_all_images() return map_queryset(ProductImageToResource, items, context=self.context) @@ -143,7 +143,7 @@ def attributes(self) -> Dict[str, Any]: } @odin.assign_field - def children(self) -> Tuple[Optional[List[resources.category.Product]]]: + def children(self) -> Tuple[Optional[List[resources.catalogue.Product]]]: """Children of parent products.""" if self.context.get("include_children", False) and self.source.is_parent: @@ -203,7 +203,7 @@ def product_to_resource( user: Optional[AbstractUser] = None, include_children: bool = False, **kwargs, -) -> Union[resources.category.Product, Iterable[resources.category.Product]]: +) -> Union[resources.catalogue.Product, Iterable[resources.catalogue.Product]]: """Map a product model to a resource. This method will except either a single product or an iterable of product @@ -229,7 +229,7 @@ def product_queryset_to_resources( user: Optional[AbstractUser] = None, include_children: bool = False, **kwargs, -) -> Iterable[resources.category.Product]: +) -> Iterable[resources.catalogue.Product]: """Map a queryset of product models to a list of resources. The request and user are optional, but if provided they are supplied to the diff --git a/tests/mappings/test_catalogue.py b/tests/mappings/test_catalogue.py index 73b41c6..96e5b91 100644 --- a/tests/mappings/test_catalogue.py +++ b/tests/mappings/test_catalogue.py @@ -1,7 +1,7 @@ from django.test import TestCase from oscar.core.loading import get_model -from oscar_odin.mappings import category +from oscar_odin.mappings import catalogue Product = get_model("catalogue", "Product") @@ -12,21 +12,21 @@ class TestProduct(TestCase): def test_mapping__basic_model_to_resource(self): product = Product.objects.first() - actual = category.product_to_resource(product) + actual = catalogue.product_to_resource(product) self.assertEqual(product.title, actual.title) def test_mapping__basic_product_with_out_of_stock_children(self): product = Product.objects.get(id=1) - actual = category.product_to_resource(product) + actual = catalogue.product_to_resource(product) self.assertEqual(product.title, actual.title) def test_mapping__where_is_a_parent_product_do_not_include_children(self): product = Product.objects.get(id=8) - actual = category.product_to_resource(product) + actual = catalogue.product_to_resource(product) self.assertEqual(product.title, actual.title) self.assertIsNone(actual.children) @@ -34,7 +34,7 @@ def test_mapping__where_is_a_parent_product_do_not_include_children(self): def test_mapping__where_is_a_parent_product_include_children(self): product = Product.objects.get(id=8) - actual = category.product_to_resource(product, include_children=True) + actual = catalogue.product_to_resource(product, include_children=True) self.assertEqual(product.title, actual.title) self.assertIsNotNone(actual.children) diff --git a/tests/resources/test_catalogue.py b/tests/resources/test_catalogue.py index 3849e8b..9468621 100644 --- a/tests/resources/test_catalogue.py +++ b/tests/resources/test_catalogue.py @@ -5,6 +5,6 @@ class TestProduct(TestCase): def test_init(self): - target = resources.category.Product() + target = resources.catalogue.Product() self.assertIsNotNone(target)