test: cleanup BOM in test_routing and prevent overlap in test_job_card (#25180)

This commit is contained in:
Sagar Vora 2021-04-03 20:25:19 +05:30 committed by GitHub
parent 37b826b988
commit 993cf8c2cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 14 deletions

View File

@ -13,8 +13,15 @@ from erpnext.manufacturing.doctype.workstation.test_workstation import make_work
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
class TestRouting(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.item_code = "Test Routing Item - A"
@classmethod
def tearDownClass(cls):
frappe.db.sql('delete from tabBOM where item=%s', cls.item_code)
def test_sequence_id(self):
item_code = "Test Routing Item - A"
operations = [{"operation": "Test Operation A", "workstation": "Test Workstation A", "time_in_mins": 30},
{"operation": "Test Operation B", "workstation": "Test Workstation A", "time_in_mins": 20}]
@ -22,8 +29,8 @@ class TestRouting(unittest.TestCase):
setup_operations(operations)
routing_doc = create_routing(routing_name="Testing Route", operations=operations)
bom_doc = setup_bom(item_code=item_code, routing=routing_doc.name)
wo_doc = make_wo_order_test_record(production_item = item_code, bom_no=bom_doc.name)
bom_doc = setup_bom(item_code=self.item_code, routing=routing_doc.name)
wo_doc = make_wo_order_test_record(production_item = self.item_code, bom_no=bom_doc.name)
for row in routing_doc.operations:
self.assertEqual(row.sequence_id, row.idx)

View File

@ -371,14 +371,14 @@ class TestWorkOrder(unittest.TestCase):
def test_job_card(self):
stock_entries = []
data = frappe.get_cached_value('BOM',
{'docstatus': 1, 'with_operations': 1, 'company': '_Test Company'}, ['name', 'item'])
bom = frappe.get_doc('BOM', {
'docstatus': 1,
'with_operations': 1,
'company': '_Test Company'
})
bom, bom_item = data
bom_doc = frappe.get_doc('BOM', bom)
work_order = make_wo_order_test_record(item=bom_item, qty=1,
bom_no=bom, source_warehouse="_Test Warehouse - _TC")
work_order = make_wo_order_test_record(item=bom.item, qty=1,
bom_no=bom.name, source_warehouse="_Test Warehouse - _TC")
for row in work_order.required_items:
stock_entry_doc = test_stock_entry.make_stock_entry(item_code=row.item_code,
@ -390,14 +390,14 @@ class TestWorkOrder(unittest.TestCase):
stock_entries.append(ste)
job_cards = frappe.get_all('Job Card', filters = {'work_order': work_order.name})
self.assertEqual(len(job_cards), len(bom_doc.operations))
self.assertEqual(len(job_cards), len(bom.operations))
for i, job_card in enumerate(job_cards):
doc = frappe.get_doc("Job Card", job_card)
doc.append("time_logs", {
"from_time": now(),
"hours": i,
"to_time": add_to_date(now(), i),
"from_time": add_to_date(None, i),
"hours": 1,
"to_time": add_to_date(None, i + 1),
"completed_qty": doc.for_quantity
})
doc.submit()