From 1dbb6545001e0c20d3dd2e20b78acfe44694946e Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 14 Mar 2022 17:43:28 +0530 Subject: [PATCH] test: refactor BOM quality template test --- erpnext/manufacturing/doctype/bom/bom.py | 2 +- erpnext/manufacturing/doctype/bom/test_bom.py | 17 ++++++----------- .../test_records.json | 1 + 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index e9bb345c574..797115abb27 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -419,7 +419,7 @@ class BOM(WebsiteGenerator): def clear_inspection(self): if not self.inspection_required: - self.set('quality_inspection_template', None) + self.quality_inspection_template = None def validate_main_item(self): """ Validate main FG item""" diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py index ad893a43ec3..e9fb4862a05 100644 --- a/erpnext/manufacturing/doctype/bom/test_bom.py +++ b/erpnext/manufacturing/doctype/bom/test_bom.py @@ -6,7 +6,6 @@ from collections import deque from functools import partial import frappe -from frappe.test_runner import make_test_records from frappe.tests.utils import FrappeTestCase from frappe.utils import cstr, flt @@ -20,15 +19,9 @@ from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import from erpnext.tests.test_subcontracting import set_backflush_based_on test_records = frappe.get_test_records('BOM') +test_dependencies = ["Item", "Quality Inspection Template"] class TestBOM(FrappeTestCase): - def setUp(self): - if not frappe.get_value('Item', '_Test Item'): - make_test_records('Item') - - if not frappe.get_value('Quality Inspection Template', '_Test Quality Inspection Template'): - make_test_records('Quality Inspection_Template') - def test_get_items(self): from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict items_dict = get_bom_items_as_dict(bom=get_default_bom(), @@ -453,17 +446,19 @@ class TestBOM(FrappeTestCase): def test_clear_inpection_quality(self): - bom = frappe.copy_doc(test_records[2]) - bom.is_active = 0 + bom = frappe.copy_doc(test_records[2], ignore_no_copy=True) + bom.docstatus = 0 + bom.is_default = 0 bom.quality_inspection_template = "_Test Quality Inspection Template" bom.inspection_required = 1 bom.save() + bom.reload() self.assertEqual(bom.quality_inspection_template, '_Test Quality Inspection Template') bom.inspection_required = 0 bom.save() - bom.load_from_db() + bom.reload() self.assertEqual(bom.quality_inspection_template, None) diff --git a/erpnext/stock/doctype/quality_inspection_template/test_records.json b/erpnext/stock/doctype/quality_inspection_template/test_records.json index a1b6415b54e..980f49a80aa 100644 --- a/erpnext/stock/doctype/quality_inspection_template/test_records.json +++ b/erpnext/stock/doctype/quality_inspection_template/test_records.json @@ -1,6 +1,7 @@ [ { "quality_inspection_template_name" : "_Test Quality Inspection Template", + "doctype": "Quality Inspection Template", "item_quality_inspection_parameter" : [ { "specification": "_Test Param",