test: use different product attribute value; cleanup (#25043)
Co-authored-by: Sagar Vora <sagar@resilient.tech>
diff --git a/erpnext/portal/product_configurator/test_product_configurator.py b/erpnext/portal/product_configurator/test_product_configurator.py
index 97042db..3521e7e 100644
--- a/erpnext/portal/product_configurator/test_product_configurator.py
+++ b/erpnext/portal/product_configurator/test_product_configurator.py
@@ -10,8 +10,38 @@
test_dependencies = ["Item"]
class TestProductConfigurator(unittest.TestCase):
- def setUp(self):
- self.create_variant_item()
+ @classmethod
+ def setUpClass(cls):
+ cls.create_variant_item()
+
+ @classmethod
+ def create_variant_item(cls):
+ if not frappe.db.exists('Item', '_Test Variant Item - 2XL'):
+ frappe.get_doc({
+ "description": "_Test Variant Item - 2XL",
+ "item_code": "_Test Variant Item - 2XL",
+ "item_name": "_Test Variant Item - 2XL",
+ "doctype": "Item",
+ "is_stock_item": 1,
+ "variant_of": "_Test Variant Item",
+ "item_group": "_Test Item Group",
+ "stock_uom": "_Test UOM",
+ "item_defaults": [{
+ "company": "_Test Company",
+ "default_warehouse": "_Test Warehouse - _TC",
+ "expense_account": "_Test Account Cost for Goods Sold - _TC",
+ "buying_cost_center": "_Test Cost Center - _TC",
+ "selling_cost_center": "_Test Cost Center - _TC",
+ "income_account": "Sales - _TC"
+ }],
+ "attributes": [
+ {
+ "attribute": "Test Size",
+ "attribute_value": "2XL"
+ }
+ ],
+ "show_variant_in_website": 1
+ }).insert()
def test_product_list(self):
template_items = frappe.get_all('Item', {'show_in_website': 1})
@@ -46,39 +76,6 @@
def test_get_products_for_website(self):
items = get_products_for_website(attribute_filters={
- 'Test Size': ['Medium']
+ 'Test Size': ['2XL']
})
self.assertEqual(len(items), 1)
-
-
- def create_variant_item(self):
- if not frappe.db.exists('Item', '_Test Variant Item 1'):
- frappe.get_doc({
- "description": "_Test Variant Item 12",
- "doctype": "Item",
- "is_stock_item": 1,
- "variant_of": "_Test Variant Item",
- "item_code": "_Test Variant Item 1",
- "item_group": "_Test Item Group",
- "item_name": "_Test Variant Item 1",
- "stock_uom": "_Test UOM",
- "item_defaults": [{
- "company": "_Test Company",
- "default_warehouse": "_Test Warehouse - _TC",
- "expense_account": "_Test Account Cost for Goods Sold - _TC",
- "buying_cost_center": "_Test Cost Center - _TC",
- "selling_cost_center": "_Test Cost Center - _TC",
- "income_account": "Sales - _TC"
- }],
- "attributes": [
- {
- "attribute": "Test Size",
- "attribute_value": "Medium"
- }
- ],
- "show_variant_in_website": 1
- }).insert()
-
-
- def tearDown(self):
- frappe.db.rollback()
\ No newline at end of file
diff --git a/erpnext/portal/product_configurator/utils.py b/erpnext/portal/product_configurator/utils.py
index 21fd7c2..d77eb2c 100644
--- a/erpnext/portal/product_configurator/utils.py
+++ b/erpnext/portal/product_configurator/utils.py
@@ -298,7 +298,7 @@
def get_items(filters=None, search=None):
- start = frappe.form_dict.start or 0
+ start = frappe.form_dict.get('start', 0)
products_settings = get_product_settings()
page_length = products_settings.products_per_page
diff --git a/erpnext/stock/doctype/item_attribute/test_records.json b/erpnext/stock/doctype/item_attribute/test_records.json
index d346979..6aa6ffd 100644
--- a/erpnext/stock/doctype/item_attribute/test_records.json
+++ b/erpnext/stock/doctype/item_attribute/test_records.json
@@ -4,10 +4,12 @@
"attribute_name": "Test Size",
"priority": 1,
"item_attribute_values": [
+ {"attribute_value": "Extra Small", "abbr": "XSL"},
{"attribute_value": "Small", "abbr": "S"},
{"attribute_value": "Medium", "abbr": "M"},
{"attribute_value": "Large", "abbr": "L"},
- {"attribute_value": "Extra Small", "abbr": "XSL"}
+ {"attribute_value": "Extra Large", "abbr": "XL"},
+ {"attribute_value": "2XL", "abbr": "2XL"}
]
},
{