mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 22:49:19 +00:00
test: use different product attribute value; cleanup (#25043)
Co-authored-by: Sagar Vora <sagar@resilient.tech>
This commit is contained in:
@@ -10,8 +10,38 @@ from erpnext.stock.doctype.item.test_item import make_item_variant
|
|||||||
test_dependencies = ["Item"]
|
test_dependencies = ["Item"]
|
||||||
|
|
||||||
class TestProductConfigurator(unittest.TestCase):
|
class TestProductConfigurator(unittest.TestCase):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
self.create_variant_item()
|
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):
|
def test_product_list(self):
|
||||||
template_items = frappe.get_all('Item', {'show_in_website': 1})
|
template_items = frappe.get_all('Item', {'show_in_website': 1})
|
||||||
@@ -46,39 +76,6 @@ class TestProductConfigurator(unittest.TestCase):
|
|||||||
|
|
||||||
def test_get_products_for_website(self):
|
def test_get_products_for_website(self):
|
||||||
items = get_products_for_website(attribute_filters={
|
items = get_products_for_website(attribute_filters={
|
||||||
'Test Size': ['Medium']
|
'Test Size': ['2XL']
|
||||||
})
|
})
|
||||||
self.assertEqual(len(items), 1)
|
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()
|
|
||||||
@@ -298,7 +298,7 @@ def get_items_by_fields(field_filters):
|
|||||||
|
|
||||||
|
|
||||||
def get_items(filters=None, search=None):
|
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()
|
products_settings = get_product_settings()
|
||||||
page_length = products_settings.products_per_page
|
page_length = products_settings.products_per_page
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,12 @@
|
|||||||
"attribute_name": "Test Size",
|
"attribute_name": "Test Size",
|
||||||
"priority": 1,
|
"priority": 1,
|
||||||
"item_attribute_values": [
|
"item_attribute_values": [
|
||||||
|
{"attribute_value": "Extra Small", "abbr": "XSL"},
|
||||||
{"attribute_value": "Small", "abbr": "S"},
|
{"attribute_value": "Small", "abbr": "S"},
|
||||||
{"attribute_value": "Medium", "abbr": "M"},
|
{"attribute_value": "Medium", "abbr": "M"},
|
||||||
{"attribute_value": "Large", "abbr": "L"},
|
{"attribute_value": "Large", "abbr": "L"},
|
||||||
{"attribute_value": "Extra Small", "abbr": "XSL"}
|
{"attribute_value": "Extra Large", "abbr": "XL"},
|
||||||
|
{"attribute_value": "2XL", "abbr": "2XL"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user