test: refactor item merge test and disable commits

This commit is contained in:
Ankush Menat 2022-03-10 16:09:26 +05:30 committed by Ankush Menat
parent 4126455975
commit b4d4ae6aa3
2 changed files with 12 additions and 10 deletions

View File

@ -371,23 +371,24 @@ class TestItem(FrappeTestCase):
variant.save() variant.save()
def test_item_merging(self): def test_item_merging(self):
create_item("Test Item for Merging 1") old = create_item(frappe.generate_hash(length=20)).name
create_item("Test Item for Merging 2") new = create_item(frappe.generate_hash(length=20)).name
make_stock_entry(item_code="Test Item for Merging 1", target="_Test Warehouse - _TC", make_stock_entry(item_code=old, target="_Test Warehouse - _TC",
qty=1, rate=100) qty=1, rate=100)
make_stock_entry(item_code="Test Item for Merging 2", target="_Test Warehouse 1 - _TC", make_stock_entry(item_code=old, target="_Test Warehouse 1 - _TC",
qty=1, rate=100)
make_stock_entry(item_code=new, target="_Test Warehouse 1 - _TC",
qty=1, rate=100) qty=1, rate=100)
frappe.rename_doc("Item", "Test Item for Merging 1", "Test Item for Merging 2", merge=True) frappe.rename_doc("Item", old, new, merge=True)
self.assertFalse(frappe.db.exists("Item", "Test Item for Merging 1")) self.assertFalse(frappe.db.exists("Item", old))
self.assertTrue(frappe.db.get_value("Bin", self.assertTrue(frappe.db.get_value("Bin",
{"item_code": "Test Item for Merging 2", "warehouse": "_Test Warehouse - _TC"})) {"item_code": new, "warehouse": "_Test Warehouse - _TC"}))
self.assertTrue(frappe.db.get_value("Bin", self.assertTrue(frappe.db.get_value("Bin",
{"item_code": "Test Item for Merging 2", "warehouse": "_Test Warehouse 1 - _TC"})) {"item_code": new, "warehouse": "_Test Warehouse 1 - _TC"}))
def test_item_merging_with_product_bundle(self): def test_item_merging_with_product_bundle(self):
from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle from erpnext.selling.doctype.product_bundle.test_product_bundle import make_product_bundle

View File

@ -118,7 +118,8 @@ def repost(doc):
doc.set_status('Failed') doc.set_status('Failed')
raise raise
finally: finally:
frappe.db.commit() if not frappe.flags.in_test:
frappe.db.commit()
def repost_sl_entries(doc): def repost_sl_entries(doc):
if doc.based_on == 'Transaction': if doc.based_on == 'Transaction':