fix: Remove delete_doc from tests
This commit is contained in:
parent
711d1acffd
commit
402d82b4c5
@ -11,32 +11,32 @@ from erpnext.buying.doctype.purchase_order.test_purchase_order import create_pur
|
|||||||
from erpnext.accounts.doctype.budget.budget import get_actual_expense, BudgetError
|
from erpnext.accounts.doctype.budget.budget import get_actual_expense, BudgetError
|
||||||
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
|
||||||
|
|
||||||
class TestBudget(unittest.TestCase):
|
class TestBudget(unittest.TestCase):
|
||||||
def test_monthly_budget_crossed_ignore(self):
|
def test_monthly_budget_crossed_ignore(self):
|
||||||
set_total_expense_zero("2013-02-28", "Cost Center")
|
set_total_expense_zero("2013-02-28", "Cost Center")
|
||||||
|
|
||||||
budget = make_budget(budget_against="Cost Center")
|
budget = make_budget(budget_against="Cost Center")
|
||||||
|
|
||||||
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||||
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", posting_date="2013-02-28", submit=True)
|
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", posting_date="2013-02-28", submit=True)
|
||||||
|
|
||||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||||
{"voucher_type": "Journal Entry", "voucher_no": jv.name}))
|
{"voucher_type": "Journal Entry", "voucher_no": jv.name}))
|
||||||
|
|
||||||
budget.cancel()
|
budget.cancel()
|
||||||
|
|
||||||
def test_monthly_budget_crossed_stop1(self):
|
def test_monthly_budget_crossed_stop1(self):
|
||||||
set_total_expense_zero("2013-02-28", "Cost Center")
|
set_total_expense_zero("2013-02-28", "Cost Center")
|
||||||
|
|
||||||
budget = make_budget(budget_against="Cost Center")
|
budget = make_budget(budget_against="Cost Center")
|
||||||
|
|
||||||
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
||||||
|
|
||||||
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||||
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", posting_date="2013-02-28")
|
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", posting_date="2013-02-28")
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv.submit)
|
self.assertRaises(BudgetError, jv.submit)
|
||||||
|
|
||||||
budget.load_from_db()
|
budget.load_from_db()
|
||||||
budget.cancel()
|
budget.cancel()
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class TestBudget(unittest.TestCase):
|
|||||||
budget = make_budget(budget_against="Cost Center")
|
budget = make_budget(budget_against="Cost Center")
|
||||||
|
|
||||||
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
||||||
|
|
||||||
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||||
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", posting_date="2013-03-02")
|
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", posting_date="2013-03-02")
|
||||||
|
|
||||||
@ -117,14 +117,14 @@ class TestBudget(unittest.TestCase):
|
|||||||
set_total_expense_zero("2013-02-28", "Project")
|
set_total_expense_zero("2013-02-28", "Project")
|
||||||
|
|
||||||
budget = make_budget(budget_against="Project")
|
budget = make_budget(budget_against="Project")
|
||||||
|
|
||||||
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
||||||
|
|
||||||
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||||
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", project="_Test Project", posting_date="2013-02-28")
|
"_Test Bank - _TC", 40000, "_Test Cost Center - _TC", project="_Test Project", posting_date="2013-02-28")
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv.submit)
|
self.assertRaises(BudgetError, jv.submit)
|
||||||
|
|
||||||
budget.load_from_db()
|
budget.load_from_db()
|
||||||
budget.cancel()
|
budget.cancel()
|
||||||
|
|
||||||
@ -132,31 +132,31 @@ class TestBudget(unittest.TestCase):
|
|||||||
set_total_expense_zero("2013-02-28", "Cost Center")
|
set_total_expense_zero("2013-02-28", "Cost Center")
|
||||||
|
|
||||||
budget = make_budget(budget_against="Cost Center")
|
budget = make_budget(budget_against="Cost Center")
|
||||||
|
|
||||||
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||||
"_Test Bank - _TC", 150000, "_Test Cost Center - _TC", posting_date="2013-03-28")
|
"_Test Bank - _TC", 150000, "_Test Cost Center - _TC", posting_date="2013-03-28")
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv.submit)
|
self.assertRaises(BudgetError, jv.submit)
|
||||||
|
|
||||||
budget.cancel()
|
budget.cancel()
|
||||||
|
|
||||||
def test_yearly_budget_crossed_stop2(self):
|
def test_yearly_budget_crossed_stop2(self):
|
||||||
set_total_expense_zero("2013-02-28", "Project")
|
set_total_expense_zero("2013-02-28", "Project")
|
||||||
|
|
||||||
budget = make_budget(budget_against="Project")
|
budget = make_budget(budget_against="Project")
|
||||||
|
|
||||||
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||||
"_Test Bank - _TC", 150000, "_Test Cost Center - _TC", project="_Test Project", posting_date="2013-03-28")
|
"_Test Bank - _TC", 150000, "_Test Cost Center - _TC", project="_Test Project", posting_date="2013-03-28")
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv.submit)
|
self.assertRaises(BudgetError, jv.submit)
|
||||||
|
|
||||||
budget.cancel()
|
budget.cancel()
|
||||||
|
|
||||||
def test_monthly_budget_on_cancellation1(self):
|
def test_monthly_budget_on_cancellation1(self):
|
||||||
set_total_expense_zero("2013-02-28", "Cost Center")
|
set_total_expense_zero("2013-02-28", "Cost Center")
|
||||||
|
|
||||||
budget = make_budget(budget_against="Cost Center")
|
budget = make_budget(budget_against="Cost Center")
|
||||||
|
|
||||||
jv1 = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
jv1 = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||||
"_Test Bank - _TC", 20000, "_Test Cost Center - _TC", posting_date="2013-02-28", submit=True)
|
"_Test Bank - _TC", 20000, "_Test Cost Center - _TC", posting_date="2013-02-28", submit=True)
|
||||||
|
|
||||||
@ -170,9 +170,9 @@ class TestBudget(unittest.TestCase):
|
|||||||
{"voucher_type": "Journal Entry", "voucher_no": jv2.name}))
|
{"voucher_type": "Journal Entry", "voucher_no": jv2.name}))
|
||||||
|
|
||||||
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv1.cancel)
|
self.assertRaises(BudgetError, jv1.cancel)
|
||||||
|
|
||||||
budget.load_from_db()
|
budget.load_from_db()
|
||||||
budget.cancel()
|
budget.cancel()
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ class TestBudget(unittest.TestCase):
|
|||||||
set_total_expense_zero("2013-02-28", "Project")
|
set_total_expense_zero("2013-02-28", "Project")
|
||||||
|
|
||||||
budget = make_budget(budget_against="Project")
|
budget = make_budget(budget_against="Project")
|
||||||
|
|
||||||
jv1 = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
jv1 = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||||
"_Test Bank - _TC", 20000, "_Test Cost Center - _TC", posting_date="2013-02-28", submit=True, project="_Test Project")
|
"_Test Bank - _TC", 20000, "_Test Cost Center - _TC", posting_date="2013-02-28", submit=True, project="_Test Project")
|
||||||
|
|
||||||
@ -194,16 +194,16 @@ class TestBudget(unittest.TestCase):
|
|||||||
{"voucher_type": "Journal Entry", "voucher_no": jv2.name}))
|
{"voucher_type": "Journal Entry", "voucher_no": jv2.name}))
|
||||||
|
|
||||||
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv1.cancel)
|
self.assertRaises(BudgetError, jv1.cancel)
|
||||||
|
|
||||||
budget.load_from_db()
|
budget.load_from_db()
|
||||||
budget.cancel()
|
budget.cancel()
|
||||||
|
|
||||||
def test_monthly_budget_against_group_cost_center(self):
|
def test_monthly_budget_against_group_cost_center(self):
|
||||||
set_total_expense_zero("2013-02-28", "Cost Center")
|
set_total_expense_zero("2013-02-28", "Cost Center")
|
||||||
set_total_expense_zero("2013-02-28", "Cost Center", "_Test Cost Center 2 - _TC")
|
set_total_expense_zero("2013-02-28", "Cost Center", "_Test Cost Center 2 - _TC")
|
||||||
|
|
||||||
budget = make_budget(budget_against="Cost Center", cost_center="_Test Company - _TC")
|
budget = make_budget(budget_against="Cost Center", cost_center="_Test Company - _TC")
|
||||||
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ class TestBudget(unittest.TestCase):
|
|||||||
"_Test Bank - _TC", 40000, "_Test Cost Center 2 - _TC", posting_date="2013-02-28")
|
"_Test Bank - _TC", 40000, "_Test Cost Center 2 - _TC", posting_date="2013-02-28")
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv.submit)
|
self.assertRaises(BudgetError, jv.submit)
|
||||||
|
|
||||||
budget.load_from_db()
|
budget.load_from_db()
|
||||||
budget.cancel()
|
budget.cancel()
|
||||||
|
|
||||||
@ -239,8 +239,6 @@ class TestBudget(unittest.TestCase):
|
|||||||
budget.cancel()
|
budget.cancel()
|
||||||
jv.cancel()
|
jv.cancel()
|
||||||
|
|
||||||
frappe.delete_doc('Journal Entry', jv.name)
|
|
||||||
frappe.delete_doc('Cost Center', cost_center)
|
|
||||||
|
|
||||||
def set_total_expense_zero(posting_date, budget_against_field=None, budget_against_CC=None):
|
def set_total_expense_zero(posting_date, budget_against_field=None, budget_against_CC=None):
|
||||||
if budget_against_field == "Project":
|
if budget_against_field == "Project":
|
||||||
@ -256,7 +254,7 @@ def set_total_expense_zero(posting_date, budget_against_field=None, budget_again
|
|||||||
"budget_against_field": budget_against_field,
|
"budget_against_field": budget_against_field,
|
||||||
"budget_against": budget_against
|
"budget_against": budget_against
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if existing_expense:
|
if existing_expense:
|
||||||
if budget_against_field == "Cost Center":
|
if budget_against_field == "Cost Center":
|
||||||
make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
make_journal_entry("_Test Account Cost for Goods Sold - _TC",
|
||||||
@ -281,13 +279,13 @@ def make_budget(**args):
|
|||||||
frappe.db.sql("delete from `tabBudget Account` where parent = %(name)s", d)
|
frappe.db.sql("delete from `tabBudget Account` where parent = %(name)s", d)
|
||||||
|
|
||||||
budget = frappe.new_doc("Budget")
|
budget = frappe.new_doc("Budget")
|
||||||
|
|
||||||
if budget_against == "Project":
|
if budget_against == "Project":
|
||||||
budget.project = "_Test Project"
|
budget.project = "_Test Project"
|
||||||
else:
|
else:
|
||||||
budget.cost_center =cost_center or "_Test Cost Center - _TC"
|
budget.cost_center =cost_center or "_Test Cost Center - _TC"
|
||||||
|
|
||||||
|
|
||||||
budget.fiscal_year = "_Test Fiscal Year 2013"
|
budget.fiscal_year = "_Test Fiscal Year 2013"
|
||||||
budget.monthly_distribution = "_Test Distribution"
|
budget.monthly_distribution = "_Test Distribution"
|
||||||
budget.company = "_Test Company"
|
budget.company = "_Test Company"
|
||||||
@ -299,7 +297,7 @@ def make_budget(**args):
|
|||||||
"account": "_Test Account Cost for Goods Sold - _TC",
|
"account": "_Test Account Cost for Goods Sold - _TC",
|
||||||
"budget_amount": 100000
|
"budget_amount": 100000
|
||||||
})
|
})
|
||||||
|
|
||||||
if args.applicable_on_material_request:
|
if args.applicable_on_material_request:
|
||||||
budget.applicable_on_material_request = 1
|
budget.applicable_on_material_request = 1
|
||||||
budget.action_if_annual_budget_exceeded_on_mr = args.action_if_annual_budget_exceeded_on_mr or 'Warn'
|
budget.action_if_annual_budget_exceeded_on_mr = args.action_if_annual_budget_exceeded_on_mr or 'Warn'
|
||||||
|
|||||||
@ -49,7 +49,6 @@ class TestLoyaltyProgram(unittest.TestCase):
|
|||||||
# cancel and delete
|
# cancel and delete
|
||||||
for d in [si_redeem, si_original]:
|
for d in [si_redeem, si_original]:
|
||||||
d.cancel()
|
d.cancel()
|
||||||
frappe.delete_doc('Sales Invoice', d.name)
|
|
||||||
|
|
||||||
def test_loyalty_points_earned_multiple_tier(self):
|
def test_loyalty_points_earned_multiple_tier(self):
|
||||||
frappe.db.set_value("Customer", "Test Loyalty Customer", "loyalty_program", "Test Multiple Loyalty")
|
frappe.db.set_value("Customer", "Test Loyalty Customer", "loyalty_program", "Test Multiple Loyalty")
|
||||||
@ -91,7 +90,6 @@ class TestLoyaltyProgram(unittest.TestCase):
|
|||||||
# cancel and delete
|
# cancel and delete
|
||||||
for d in [si_redeem, si_original]:
|
for d in [si_redeem, si_original]:
|
||||||
d.cancel()
|
d.cancel()
|
||||||
frappe.delete_doc('Sales Invoice', d.name)
|
|
||||||
|
|
||||||
def test_cancel_sales_invoice(self):
|
def test_cancel_sales_invoice(self):
|
||||||
''' cancelling the sales invoice should cancel the earned points'''
|
''' cancelling the sales invoice should cancel the earned points'''
|
||||||
@ -143,7 +141,6 @@ class TestLoyaltyProgram(unittest.TestCase):
|
|||||||
d.cancel()
|
d.cancel()
|
||||||
except frappe.TimestampMismatchError:
|
except frappe.TimestampMismatchError:
|
||||||
frappe.get_doc('Sales Invoice', d.name).cancel()
|
frappe.get_doc('Sales Invoice', d.name).cancel()
|
||||||
frappe.delete_doc('Sales Invoice', d.name)
|
|
||||||
|
|
||||||
def test_loyalty_points_for_dashboard(self):
|
def test_loyalty_points_for_dashboard(self):
|
||||||
doc = frappe.get_doc('Customer', 'Test Loyalty Customer')
|
doc = frappe.get_doc('Customer', 'Test Loyalty Customer')
|
||||||
|
|||||||
@ -818,7 +818,6 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEqual(expected_gl_entries[i][2], gle.credit)
|
self.assertEqual(expected_gl_entries[i][2], gle.credit)
|
||||||
|
|
||||||
si.cancel()
|
si.cancel()
|
||||||
frappe.delete_doc('Sales Invoice', si.name)
|
|
||||||
gle = frappe.db.sql("""select * from `tabGL Entry`
|
gle = frappe.db.sql("""select * from `tabGL Entry`
|
||||||
where voucher_type='Sales Invoice' and voucher_no=%s""", si.name)
|
where voucher_type='Sales Invoice' and voucher_no=%s""", si.name)
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,6 @@ class TestTaxWithholdingCategory(unittest.TestCase):
|
|||||||
#delete invoices to avoid clashing
|
#delete invoices to avoid clashing
|
||||||
for d in invoices:
|
for d in invoices:
|
||||||
d.cancel()
|
d.cancel()
|
||||||
frappe.delete_doc("Purchase Invoice", d.name)
|
|
||||||
|
|
||||||
def test_single_threshold_tds(self):
|
def test_single_threshold_tds(self):
|
||||||
invoices = []
|
invoices = []
|
||||||
@ -83,7 +82,6 @@ class TestTaxWithholdingCategory(unittest.TestCase):
|
|||||||
# delete invoices to avoid clashing
|
# delete invoices to avoid clashing
|
||||||
for d in invoices:
|
for d in invoices:
|
||||||
d.cancel()
|
d.cancel()
|
||||||
frappe.delete_doc("Purchase Invoice", d.name)
|
|
||||||
|
|
||||||
def test_single_threshold_tds_with_previous_vouchers(self):
|
def test_single_threshold_tds_with_previous_vouchers(self):
|
||||||
invoices = []
|
invoices = []
|
||||||
@ -102,7 +100,6 @@ class TestTaxWithholdingCategory(unittest.TestCase):
|
|||||||
# delete invoices to avoid clashing
|
# delete invoices to avoid clashing
|
||||||
for d in invoices:
|
for d in invoices:
|
||||||
d.cancel()
|
d.cancel()
|
||||||
frappe.delete_doc("Purchase Invoice", d.name)
|
|
||||||
|
|
||||||
def create_purchase_invoice(**args):
|
def create_purchase_invoice(**args):
|
||||||
# return sales invoice doc object
|
# return sales invoice doc object
|
||||||
|
|||||||
@ -456,8 +456,6 @@ class TestAsset(unittest.TestCase):
|
|||||||
self.assertEqual(gle, expected_gle)
|
self.assertEqual(gle, expected_gle)
|
||||||
|
|
||||||
si.cancel()
|
si.cancel()
|
||||||
frappe.delete_doc("Sales Invoice", si.name)
|
|
||||||
|
|
||||||
self.assertEqual(frappe.db.get_value("Asset", asset.name, "status"), "Partially Depreciated")
|
self.assertEqual(frappe.db.get_value("Asset", asset.name, "status"), "Partially Depreciated")
|
||||||
|
|
||||||
def test_asset_expected_value_after_useful_life(self):
|
def test_asset_expected_value_after_useful_life(self):
|
||||||
|
|||||||
@ -45,7 +45,6 @@ class TestExpenseClaim(unittest.TestCase):
|
|||||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 700)
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 700)
|
||||||
|
|
||||||
expense_claim2.cancel()
|
expense_claim2.cancel()
|
||||||
frappe.delete_doc("Expense Claim", expense_claim2.name)
|
|
||||||
|
|
||||||
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
|
self.assertEqual(frappe.db.get_value("Task", task_name, "total_expense_claim"), 200)
|
||||||
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
|
self.assertEqual(frappe.db.get_value("Project", "_Test Project 1", "total_expense_claim"), 200)
|
||||||
|
|||||||
@ -152,7 +152,6 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
for d in to_delete_records:
|
for d in to_delete_records:
|
||||||
stock_doc = frappe.get_doc("Stock Reconciliation", d)
|
stock_doc = frappe.get_doc("Stock Reconciliation", d)
|
||||||
stock_doc.cancel()
|
stock_doc.cancel()
|
||||||
frappe.delete_doc("Stock Reconciliation", stock_doc.name)
|
|
||||||
|
|
||||||
for d in serial_nos + serial_nos1:
|
for d in serial_nos + serial_nos1:
|
||||||
if frappe.db.exists("Serial No", d):
|
if frappe.db.exists("Serial No", d):
|
||||||
@ -203,9 +202,6 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
stock_doc = frappe.get_doc("Stock Reconciliation", d)
|
stock_doc = frappe.get_doc("Stock Reconciliation", d)
|
||||||
stock_doc.cancel()
|
stock_doc.cancel()
|
||||||
|
|
||||||
frappe.delete_doc("Batch", sr.items[0].batch_no)
|
|
||||||
for d in to_delete_records:
|
|
||||||
frappe.delete_doc("Stock Reconciliation", d)
|
|
||||||
|
|
||||||
def insert_existing_sle():
|
def insert_existing_sle():
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user