test case fixes

This commit is contained in:
Nabin Hait 2014-11-27 15:22:24 +05:30
parent 40fffc0f4d
commit 789b74257e
2 changed files with 16 additions and 7 deletions

View File

@ -5,6 +5,7 @@
from __future__ import unicode_literals
import unittest
import frappe
from frappe.utils import cstr
test_records = frappe.get_test_records('Bom')
@ -27,16 +28,22 @@ class TestBOM(unittest.TestCase):
def test_get_items_list(self):
from erpnext.manufacturing.doctype.bom.bom import get_bom_items
self.assertEquals(len(get_bom_items(bom="BOM/_Test FG Item 2/001", qty=1, fetch_exploded=1)), 3)
default_bom = frappe.db.get_value("BOM", {"item":"_Test FG Item 2", "is_default": 1})
self.assertEquals(len(get_bom_items(bom=default_bom)), 3)
def test_default_bom(self):
bom = frappe.get_doc("BOM", "BOM/_Test FG Item 2/001")
def _get_default_bom_in_item():
return cstr(frappe.db.get_value("Item", "_Test FG Item 2", "default_bom"))
bom = frappe.get_doc("BOM", {"item":"_Test FG Item 2", "is_default": 1})
self.assertEqual(_get_default_bom_in_item(), bom.name)
bom.is_active = 0
bom.save()
self.assertEqual(frappe.db.get_value("Item", "_Test FG Item 2", "default_bom"), "")
self.assertEqual(_get_default_bom_in_item(), "")
bom.is_active = 1
bom.is_default=1
bom.save()
self.assertTrue(frappe.db.get_value("Item", "_Test FG Item 2", "default_bom"), "BOM/_Test FG Item 2/001")
self.assertTrue(_get_default_bom_in_item(), bom.name)

View File

@ -18,6 +18,7 @@
"item_code": "_Test Item",
"item_group": "_Test Item Group",
"item_name": "_Test Item",
"apply_warehouse_wise_reorder_level": 1,
"item_reorder": [
{
"material_request_type": "Purchase",
@ -40,7 +41,7 @@
"income_account": "Sales - _TC",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "Yes",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
@ -191,7 +192,7 @@
"has_serial_no": "Yes",
"inspection_required": "No",
"is_asset_item": "No",
"is_pro_applicable": "Yes",
"is_pro_applicable": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
@ -274,6 +275,7 @@
{"item_attribute": "Test Size", "item_attribute_value": "Medium"},
{"item_attribute": "Test Size", "item_attribute_value": "Large"}
],
"apply_warehouse_wise_reorder_level": 1,
"item_reorder": [
{
"material_request_type": "Purchase",