From 9967a7ce021fa53eb2b8b7bc2c2b3cfa6e83b03f Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Mon, 5 Apr 2021 15:35:52 +0530 Subject: [PATCH] test: clear all existing quotations to avoid AssertionError (#25202) --- erpnext/shopping_cart/test_shopping_cart.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/erpnext/shopping_cart/test_shopping_cart.py b/erpnext/shopping_cart/test_shopping_cart.py index 470a402a4a..d857bf5f5c 100644 --- a/erpnext/shopping_cart/test_shopping_cart.py +++ b/erpnext/shopping_cart/test_shopping_cart.py @@ -56,8 +56,8 @@ class TestShoppingCart(unittest.TestCase): def test_add_to_cart(self): self.login_as_customer() - # remove from cart - self.remove_all_items_from_cart() + # clear existing quotations + self.clear_existing_quotations() # add first item update_cart("_Test Item", 1) @@ -208,10 +208,15 @@ class TestShoppingCart(unittest.TestCase): "_Test Contact For _Test Customer") frappe.set_user("test_contact_customer@example.com") - def remove_all_items_from_cart(self): - quotation = _get_cart_quotation() - quotation.flags.ignore_permissions=True - quotation.delete() + def clear_existing_quotations(self): + quotations = frappe.get_all("Quotation", filters={ + "party_name": get_party().name, + "order_type": "Shopping Cart", + "docstatus": 0 + }, order_by="modified desc", pluck="name") + + for quotation in quotations: + frappe.delete_doc("Quotation", quotation, ignore_permissions=True, force=True) def create_user_if_not_exists(self, email, first_name = None): if frappe.db.exists("User", email):