From d37d4dfdece29c04c529d7ea978aaa174d06e760 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 24 Sep 2015 15:42:21 +0530 Subject: [PATCH] [fix] applicable territory patch and tax rule tests --- .../doctype/tax_rule/test_tax_rule.py | 73 ++++++++----------- .../v6_3/convert_applicable_territory.py | 1 + 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py index 3e175fabf7..a09d81b5c6 100644 --- a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py +++ b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py @@ -12,25 +12,15 @@ test_records = frappe.get_test_records('Tax Rule') class TestTaxRule(unittest.TestCase): def setUp(self): frappe.db.sql("delete from `tabTax Rule` where use_for_shopping_cart <> 1") - - def test_customer_group(self): - tax_rule = make_tax_rule(customer= "_Test Customer", customer_group= "_Test Customer Group 1", - sales_tax_template = "_Test Sales Taxes and Charges Template") - self.assertRaises(IncorrectCustomerGroup, tax_rule.save) - - def test_supplier_type(self): - tax_rule = make_tax_rule(tax_type= "Purchase", supplier= "_Test Supplier", supplier_type= "_Test Supplier Type 1", - purchase_tax_template = "_Test Purchase Taxes and Charges Template") - self.assertRaises(IncorrectSupplierType, tax_rule.save) - - def test_conflict(self): + + def test_conflict(self): tax_rule1 = make_tax_rule(customer= "_Test Customer", sales_tax_template = "_Test Sales Taxes and Charges Template", priority = 1) tax_rule1.save() tax_rule2 = make_tax_rule(customer= "_Test Customer", sales_tax_template = "_Test Sales Taxes and Charges Template", priority = 1) - + self.assertRaises(ConflictingTaxRule, tax_rule2.save) def test_conflict_with_non_overlapping_dates(self): @@ -40,25 +30,25 @@ class TestTaxRule(unittest.TestCase): tax_rule2 = make_tax_rule(customer= "_Test Customer", sales_tax_template = "_Test Sales Taxes and Charges Template", priority = 1, to_date = "2013-01-01") - + tax_rule2.save() self.assertTrue(tax_rule2.name) - def test_conflict_with_overlapping_dates(self): + def test_conflict_with_overlapping_dates(self): tax_rule1 = make_tax_rule(customer= "_Test Customer", sales_tax_template = "_Test Sales Taxes and Charges Template", priority = 1, from_date = "2015-01-01", to_date = "2015-01-05") tax_rule1.save() tax_rule2 = make_tax_rule(customer= "_Test Customer", sales_tax_template = "_Test Sales Taxes and Charges Template", priority = 1, from_date = "2015-01-03", to_date = "2015-01-09") - + self.assertRaises(ConflictingTaxRule, tax_rule2.save) - + def test_tax_template(self): tax_rule = make_tax_rule() self.assertEquals(tax_rule.purchase_tax_template, None) - - + + def test_select_tax_rule_based_on_customer(self): make_tax_rule(customer= "_Test Customer", sales_tax_template = "_Test Sales Taxes and Charges Template", save=1) @@ -68,8 +58,8 @@ class TestTaxRule(unittest.TestCase): make_tax_rule(customer= "_Test Customer 2", sales_tax_template = "_Test Sales Taxes and Charges Template 2", save=1) - - self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer 2"}), + + self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer 2"}), "_Test Sales Taxes and Charges Template 2") def test_select_tax_rule_based_on_better_match(self): @@ -78,18 +68,18 @@ class TestTaxRule(unittest.TestCase): make_tax_rule(customer= "_Test Customer", billing_city = "Test City1", billing_state = "Test State", sales_tax_template = "_Test Sales Taxes and Charges Template 1", save=1) - - self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "billing_city": "Test City", "billing_state": "Test State"}), + + self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "billing_city": "Test City", "billing_state": "Test State"}), "_Test Sales Taxes and Charges Template") - + def test_select_tax_rule_based_on_state_match(self): - make_tax_rule(customer= "_Test Customer", shipping_state = "Test State", + make_tax_rule(customer= "_Test Customer", shipping_state = "Test State", sales_tax_template = "_Test Sales Taxes and Charges Template", save=1) - make_tax_rule(customer= "_Test Customer", shipping_state = "Test State12", + make_tax_rule(customer= "_Test Customer", shipping_state = "Test State12", sales_tax_template = "_Test Sales Taxes and Charges Template 1", priority=2, save=1) - - self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "shipping_state": "Test State"}), + + self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "shipping_state": "Test State"}), "_Test Sales Taxes and Charges Template") def test_select_tax_rule_based_on_better_priority(self): @@ -98,18 +88,18 @@ class TestTaxRule(unittest.TestCase): make_tax_rule(customer= "_Test Customer", billing_city = "Test City", sales_tax_template = "_Test Sales Taxes and Charges Template 1", priority=2, save=1) - - self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "billing_city": "Test City"}), + + self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "billing_city": "Test City"}), "_Test Sales Taxes and Charges Template 1") def test_select_tax_rule_based_cross_matching_keys(self): - make_tax_rule(customer= "_Test Customer", billing_city = "Test City", + make_tax_rule(customer= "_Test Customer", billing_city = "Test City", sales_tax_template = "_Test Sales Taxes and Charges Template", save=1) make_tax_rule(customer= "_Test Customer 1", billing_city = "Test City 1", sales_tax_template = "_Test Sales Taxes and Charges Template 1", save=1) - - self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "billing_city": "Test City 1"}), + + self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "billing_city": "Test City 1"}), None) def test_select_tax_rule_based_cross_partially_keys(self): @@ -118,24 +108,23 @@ class TestTaxRule(unittest.TestCase): make_tax_rule(billing_city = "Test City 1", sales_tax_template = "_Test Sales Taxes and Charges Template 1", save=1) - - self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "billing_city": "Test City 1"}), + + self.assertEquals(get_tax_template("2015-01-01", {"customer":"_Test Customer", "billing_city": "Test City 1"}), "_Test Sales Taxes and Charges Template 1") - + def make_tax_rule(**args): args = frappe._dict(args) - + tax_rule = frappe.new_doc("Tax Rule") - + for key, val in args.iteritems(): if key != "save": tax_rule.set(key, val) - + tax_rule.company = args.company or "_Test Company" - + if args.save: tax_rule.insert() - + return tax_rule - \ No newline at end of file diff --git a/erpnext/patches/v6_3/convert_applicable_territory.py b/erpnext/patches/v6_3/convert_applicable_territory.py index b693ce5c3f..69ec18fd84 100644 --- a/erpnext/patches/v6_3/convert_applicable_territory.py +++ b/erpnext/patches/v6_3/convert_applicable_territory.py @@ -5,6 +5,7 @@ def execute(): frappe.reload_doc("accounts", "doctype", "shipping_rule_country") frappe.reload_doctype("Price List") frappe.reload_doctype("Shipping Rule") + frappe.reload_doctype("Shopping Cart Settings") # for price list countries = frappe.db.sql_list("select name from tabCountry")