Fixed Test Cases

This commit is contained in:
Neil Trini Lasrado 2015-08-13 13:22:31 +05:30
parent 62dba50e9b
commit 9710eede00
4 changed files with 18 additions and 2 deletions

View File

@ -539,7 +539,8 @@ def create_variant(item, param):
"attribute_value": args[d]
})
variant.set("attributes", variant_attributes)
copy_attributes_to_variant(item, variant)
template = frappe.get_doc("Item", item)
copy_attributes_to_variant(template, variant)
return variant
def copy_attributes_to_variant(item, variant):

View File

@ -6,7 +6,7 @@ import unittest
import frappe
from frappe.test_runner import make_test_records
from erpnext.stock.doctype.item.item import WarehouseNotSet, ItemTemplateCannotHaveStock
from erpnext.stock.doctype.item.item import WarehouseNotSet, ItemTemplateCannotHaveStock, create_variant
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
test_ignore = ["BOM"]
@ -98,5 +98,12 @@ class TestItem(unittest.TestCase):
for key, value in to_check.iteritems():
self.assertEquals(value, details.get(key))
def test_make_item_variant(self):
if not frappe.db.exists("Item", "_Test Variant Item-S"):
variant = create_variant("_Test Variant Item", """{"Test Size": "Small"}""")
variant.item_code = "_Test Variant Item-S"
variant.item_name = "_Test Variant Item-S"
variant.save()
test_records = frappe.get_test_records('Item')

View File

@ -273,6 +273,11 @@
"item_name": "_Test Variant Item",
"stock_uom": "_Test UOM",
"has_variants": 1,
"attributes": [
{
"attribute": "Test Size"
}
],
"apply_warehouse_wise_reorder_level": 1,
"reorder_levels": [
{

View File

@ -67,6 +67,9 @@ class TestStockEntry(unittest.TestCase):
def test_auto_material_request(self):
self._test_auto_material_request("_Test Item")
def test_auto_material_request_for_variant(self):
self._test_auto_material_request("_Test Variant Item-S")
def _test_auto_material_request(self, item_code):
item = frappe.get_doc("Item", item_code)