Skip to content

Commit 8040739

Browse files
committed
tests ✅ update test
1 parent 08b6bd8 commit 8040739

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

oscar_odin/resources/catalogue.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ class ProductResource(OscarCatalogueResource):
102102
id: Optional[int]
103103
code: Optional[str]
104104
upc: Optional[str]
105-
structure: Optional[str] = StringField(choices=ProductModel.STRUCTURE_CHOICES)
105+
structure: Optional[str] = StringField(
106+
choices=ProductModel.STRUCTURE_CHOICES, null=True
107+
)
106108
title: Optional[str]
107109
slug: Optional[str]
108110
description: Optional[str] = ""

tests/reverse/test_catalogue.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
PRODUCT_TITLE,
2828
PRODUCT_UPC,
2929
PRODUCT_DESCRIPTION,
30+
PRODUCT_IS_DISCOUNTABLE,
3031
PRODUCTCLASS_REQUIRESSHIPPING,
3132
MODEL_IDENTIFIERS_MAPPING,
3233
)
@@ -240,14 +241,10 @@ def test_resource_default_value(self):
240241
prd = Product.objects.get(upc="1234")
241242
self.assertEqual(prd.is_discountable, False)
242243

243-
product_resource = ProductResource(
244-
upc="1234",
245-
title="bat",
246-
slug="asdf",
247-
structure=Product.STANDALONE,
248-
product_class=product_class,
244+
product_resource = ProductResource(upc="1234", is_discountable=True)
245+
_, errors = products_to_db(
246+
product_resource, fields_to_update=[PRODUCT_IS_DISCOUNTABLE]
249247
)
250-
_, errors = products_to_db(product_resource)
251248
self.assertEqual(len(errors), 0)
252249
prd.refresh_from_db()
253250
# Default value of is_discountable is considered from the ProductResource

0 commit comments

Comments
 (0)