From 0f5f5846515ebd9f606295d355fa9fea2279e442 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 3 May 2013 14:34:12 +0530 Subject: [PATCH] [stock entry] [test] fixes in test cases --- accounts/doctype/sales_invoice/sales_invoice.py | 2 +- stock/doctype/stock_entry/test_stock_entry.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 18611793fe..87f73c19ab 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -157,7 +157,7 @@ class DocType(SellingController): # fetch pos details, if they are not fetched if cint(self.doc.is_pos): self.set_pos_fields(for_validate=True) - + def update_time_log_batch(self, sales_invoice): for d in self.doclist.get({"doctype":"Sales Invoice Item"}): if d.time_log_batch: diff --git a/stock/doctype/stock_entry/test_stock_entry.py b/stock/doctype/stock_entry/test_stock_entry.py index 7c406f8e8c..c3ce2d7f40 100644 --- a/stock/doctype/stock_entry/test_stock_entry.py +++ b/stock/doctype/stock_entry/test_stock_entry.py @@ -25,6 +25,8 @@ class TestStockEntry(unittest.TestCase): where item_code='_Test Item'""") self.assertTrue(mr_name) + + webnotes.conn.set_default("company", self.old_default_company) def test_warehouse_company_validation(self): from stock.doctype.stock_ledger_entry.stock_ledger_entry import InvalidWarehouseCompany @@ -71,7 +73,7 @@ class TestStockEntry(unittest.TestCase): webnotes.defaults.set_global_default("auto_inventory_accounting", 0) def test_material_issue_gl_entry(self): - webnotes.conn.sql("delete from `tabStock Ledger Entry`") + self._clear_stock() webnotes.defaults.set_global_default("auto_inventory_accounting", 1) mr = webnotes.bean(copy=test_records[0]) @@ -111,9 +113,10 @@ class TestStockEntry(unittest.TestCase): ) webnotes.defaults.set_global_default("auto_inventory_accounting", 0) + webnotes.conn.set_default("company", self.old_default_company) def test_material_transfer_gl_entry(self): - webnotes.conn.sql("delete from `tabStock Ledger Entry`") + self._clear_stock() webnotes.defaults.set_global_default("auto_inventory_accounting", 1) mr = webnotes.bean(copy=test_records[0]) @@ -145,6 +148,7 @@ class TestStockEntry(unittest.TestCase): self.assertFalse(gl_entries) webnotes.defaults.set_global_default("auto_inventory_accounting", 0) + webnotes.conn.set_default("company", self.old_default_company) def check_stock_ledger_entries(self, voucher_type, voucher_no, expected_sle): # check stock ledger entries @@ -173,6 +177,9 @@ class TestStockEntry(unittest.TestCase): def _clear_stock(self): webnotes.conn.sql("delete from `tabStock Ledger Entry`") webnotes.conn.sql("""delete from `tabBin`""") + + self.old_default_company = webnotes.conn.get_default("company") + webnotes.conn.set_default("company", "_Test Company") def _insert_material_receipt(self): self._clear_stock() @@ -185,6 +192,8 @@ class TestStockEntry(unittest.TestCase): se2.insert() se2.submit() + webnotes.conn.set_default("company", self.old_default_company) + def _get_actual_qty(self): return flt(webnotes.conn.get_value("Bin", {"item_code": "_Test Item", "warehouse": "_Test Warehouse"}, "actual_qty")) @@ -463,6 +472,8 @@ class TestStockEntry(unittest.TestCase): self.assertEquals(actual_qty_1 - 5, actual_qty_2) + webnotes.conn.set_default("company", self.old_default_company) + return se, pr.doc.name def test_over_stock_return(self): @@ -563,6 +574,8 @@ class TestStockEntry(unittest.TestCase): self.assertEquals(actual_qty_1 - 5, actual_qty_2) + webnotes.conn.set_default("company", self.old_default_company) + return se, pr.doc.name test_records = [