fix shipping rule test cases (copy name with copy_doc)

This commit is contained in:
Pratik Vyas 2014-05-16 15:19:51 +05:30
parent 3d8f8f68d8
commit fa7444ec94

View File

@ -10,11 +10,13 @@ test_records = frappe.get_test_records('Shipping Rule')
class TestShippingRule(unittest.TestCase): class TestShippingRule(unittest.TestCase):
def test_from_greater_than_to(self): def test_from_greater_than_to(self):
shipping_rule = frappe.copy_doc(test_records[0]) shipping_rule = frappe.copy_doc(test_records[0])
shipping_rule.name = test_records[0].get('name')
shipping_rule.get("shipping_rule_conditions")[0].from_value = 101 shipping_rule.get("shipping_rule_conditions")[0].from_value = 101
self.assertRaises(FromGreaterThanToError, shipping_rule.insert) self.assertRaises(FromGreaterThanToError, shipping_rule.insert)
def test_many_zero_to_values(self): def test_many_zero_to_values(self):
shipping_rule = frappe.copy_doc(test_records[0]) shipping_rule = frappe.copy_doc(test_records[0])
shipping_rule.name = test_records[0].get('name')
shipping_rule.get("shipping_rule_conditions")[0].to_value = 0 shipping_rule.get("shipping_rule_conditions")[0].to_value = 0
self.assertRaises(ManyBlankToValuesError, shipping_rule.insert) self.assertRaises(ManyBlankToValuesError, shipping_rule.insert)
@ -27,8 +29,9 @@ class TestShippingRule(unittest.TestCase):
((50, 150), (50, 150)), ((50, 150), (50, 150)),
]: ]:
shipping_rule = frappe.copy_doc(test_records[0]) shipping_rule = frappe.copy_doc(test_records[0])
shipping_rule.name = test_records[0].get('name')
shipping_rule.get("shipping_rule_conditions")[0].from_value = range_a[0] shipping_rule.get("shipping_rule_conditions")[0].from_value = range_a[0]
shipping_rule.get("shipping_rule_conditions")[0].to_value = range_a[1] shipping_rule.get("shipping_rule_conditions")[0].to_value = range_a[1]
shipping_rule.get("shipping_rule_conditions")[1].from_value = range_b[0] shipping_rule.get("shipping_rule_conditions")[1].from_value = range_b[0]
shipping_rule.get("shipping_rule_conditions")[1].to_value = range_b[1] shipping_rule.get("shipping_rule_conditions")[1].to_value = range_b[1]
self.assertRaises(OverlappingConditionError, shipping_rule.insert) self.assertRaises(OverlappingConditionError, shipping_rule.insert)