-
Notifications
You must be signed in to change notification settings - Fork 4
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
Added tools to track which fields_to_update after mapping. #55
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
PRODUCT_META_TITLE = "Product.meta_title" | ||
PRODUCT_META_DESCRIPTION = "Product.meta_description" | ||
PRODUCT_IS_DISCOUNTABLE = "Product.is_discountable" | ||
PRODUCT_PRIORITY = "Product.priority" | ||
|
||
PRODUCTCLASS_SLUG = "ProductClass.slug" | ||
PRODUCTCLASS_REQUIRESSHIPPING = "ProductClass.requires_shipping" | ||
|
@@ -55,7 +56,7 @@ | |
PRODUCT_META_TITLE, | ||
PRODUCT_META_DESCRIPTION, | ||
PRODUCT_IS_DISCOUNTABLE, | ||
PRODUCT_PARENT, | ||
PRODUCT_PRIORITY, | ||
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. Do we need to remove parent field from this list? 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. It is in this list twice |
||
] | ||
|
||
ALL_PRODUCTCLASS_FIELDS = [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
|
||
from oscar_odin.mappings import catalogue | ||
|
||
from oscar_odin.utils import get_mapped_fields | ||
|
||
Product = get_model("catalogue", "Product") | ||
|
||
|
||
|
@@ -75,3 +77,127 @@ def test_queryset_to_resources_include_children_num_queries(self): | |
queryset, include_children=True | ||
) | ||
dict_codec.dump(resources, include_type_field=False) | ||
|
||
def test_get_mapped_fields(self): | ||
product_to_model_fields = get_mapped_fields(catalogue.ProductToModel) | ||
self.assertListEqual( | ||
sorted(product_to_model_fields), | ||
[ | ||
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. Maybe define this list in a variable 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. Well this is a test so ... |
||
"attributes", | ||
"categories", | ||
"children", | ||
"date_created", | ||
"date_updated", | ||
"description", | ||
"id", | ||
"images", | ||
"is_discountable", | ||
"is_public", | ||
"meta_description", | ||
"meta_title", | ||
"parent", | ||
"priority", | ||
"product_class", | ||
"rating", | ||
"recommended_products", | ||
"slug", | ||
"stockrecords", | ||
"structure", | ||
"title", | ||
"upc", | ||
], | ||
) | ||
|
||
model_to_product_fields = get_mapped_fields(catalogue.ProductToResource) | ||
self.assertListEqual( | ||
sorted(model_to_product_fields), | ||
[ | ||
"attributes", | ||
"availability", | ||
"categories", | ||
"children", | ||
"currency", | ||
"date_created", | ||
"date_updated", | ||
"description", | ||
"id", | ||
"images", | ||
"is_available_to_buy", | ||
"is_discountable", | ||
"is_public", | ||
"meta_description", | ||
"meta_title", | ||
"parent", | ||
"price", | ||
"priority", | ||
"product_class", | ||
"rating", | ||
"recommended_products", | ||
"slug", | ||
"stockrecords", | ||
"structure", | ||
"title", | ||
"upc", | ||
], | ||
) | ||
|
||
fieldz = get_mapped_fields(catalogue.ProductToModel, *model_to_product_fields) | ||
self.assertListEqual( | ||
sorted(fieldz), | ||
[ | ||
"attributes", | ||
"categories", | ||
"children", | ||
"date_created", | ||
"date_updated", | ||
"description", | ||
"id", | ||
"images", | ||
"is_discountable", | ||
"is_public", | ||
"meta_description", | ||
"meta_title", | ||
"parent", | ||
"priority", | ||
"product_class", | ||
"rating", | ||
"recommended_products", | ||
"slug", | ||
"stockrecords", | ||
"structure", | ||
"title", | ||
"upc", | ||
], | ||
) | ||
|
||
demfields = catalogue.ProductToModel.get_fields_impacted_by_mapping( | ||
*model_to_product_fields | ||
) | ||
self.assertListEqual( | ||
sorted(demfields), | ||
[ | ||
"Category.code", | ||
"Product.description", | ||
"Product.is_discountable", | ||
"Product.is_public", | ||
"Product.meta_description", | ||
"Product.meta_title", | ||
"Product.parent", | ||
"Product.priority", | ||
"Product.slug", | ||
"Product.structure", | ||
"Product.title", | ||
"Product.upc", | ||
"ProductClass.slug", | ||
"ProductImage.caption", | ||
"ProductImage.code", | ||
"ProductImage.display_order", | ||
"ProductImage.original", | ||
"StockRecord.num_allocated", | ||
"StockRecord.num_in_stock", | ||
"StockRecord.partner", | ||
"StockRecord.partner_sku", | ||
"StockRecord.price", | ||
"StockRecord.price_currency", | ||
], | ||
) |
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.
Do we have priority field for product model?
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.
yup