From 68f66a7e8b22fddf66fabf35e643aa6806f7a603 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 13 Aug 2015 17:10:53 +0530 Subject: [PATCH] fixed Test Cases --- erpnext/stock/doctype/item/test_item.py | 7 +++++++ erpnext/stock/doctype/item_attribute/item_attribute.py | 2 +- erpnext/stock/doctype/stock_entry/test_stock_entry.py | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index 8db2d2d61b..488bd05716 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -106,4 +106,11 @@ class TestItem(unittest.TestCase): variant.item_name = "_Test Variant Item-S" variant.save() +def make_item_variant(): + 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') diff --git a/erpnext/stock/doctype/item_attribute/item_attribute.py b/erpnext/stock/doctype/item_attribute/item_attribute.py index 8350bed454..766668fbc8 100644 --- a/erpnext/stock/doctype/item_attribute/item_attribute.py +++ b/erpnext/stock/doctype/item_attribute/item_attribute.py @@ -42,6 +42,6 @@ class ItemAttribute(Document): variant_attributes = frappe.db.sql("select DISTINCT attribute_value from `tabVariant Attribute` where attribute=%s", self.name) if variant_attributes: for d in variant_attributes: - if d[0] not in attribute_values: + if d[0] and d[0] not in attribute_values: frappe.throw(_("Attribute Value {0} cannot be removed from {1} as Item Variants \ exist with this Attribute.").format(d[0], self.name)) diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 29f2a21a01..174bc1a6df 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -64,8 +64,10 @@ class TestStockEntry(unittest.TestCase): self.assertEqual([[1, 20],[1, 30]], eval(sle.stock_queue)) frappe.db.set_default("allow_negative_stock", 0) - + def test_auto_material_request(self): + from erpnext.stock.doctype.item.test_item import make_item_variant + make_item_variant() self._test_auto_material_request("_Test Item") def test_auto_material_request_for_variant(self):