test: check index creation on item table

This commit is contained in:
Ankush Menat 2021-05-23 12:38:15 +05:30
parent b9fa12d572
commit f5a937bc45
No known key found for this signature in database
GPG Key ID: 8EA82E09BBD13AAF

View File

@ -487,6 +487,20 @@ class TestItem(unittest.TestCase):
new_barcode.barcode_type = 'EAN'
self.assertRaises(InvalidBarcode, item_doc.save)
def test_index_creation(self):
"check if index is getting created in db"
from erpnext.stock.doctype.item.item import on_doctype_update
on_doctype_update()
indices = frappe.db.sql("show index from tabItem", as_dict=1)
expected_columns = {"item_code", "item_name", "item_group", "route"}
for index in indices:
expected_columns.discard(index.get("Column_name"))
if expected_columns:
self.fail(f"Expected db index on these columns: {', '.join(expected_columns)}")
def set_item_variant_settings(fields):
doc = frappe.get_doc('Item Variant Settings')
doc.set('fields', fields)