refactor: use cls.globalTestRecords instead of declaring test_records

This commit is contained in:
David
2024-10-11 04:58:12 +02:00
parent d8b0b92925
commit 56c99fe7e1
32 changed files with 220 additions and 284 deletions

View File

@@ -41,7 +41,7 @@ class TestQuotation(IntegrationTestCase):
def test_make_sales_order_terms_copied(self):
from erpnext.selling.doctype.quotation.quotation import make_sales_order
quotation = frappe.copy_doc(test_records[0])
quotation = frappe.copy_doc(self.globalTestRecords["Quotation"][0])
quotation.transaction_date = nowdate()
quotation.valid_till = add_months(quotation.transaction_date, 1)
quotation.insert()
@@ -90,7 +90,7 @@ class TestQuotation(IntegrationTestCase):
maintain_rate = frappe.db.get_single_value("Selling Settings", "maintain_same_sales_rate")
frappe.db.set_single_value("Selling Settings", "maintain_same_sales_rate", 1)
quotation = frappe.copy_doc(test_records[0])
quotation = frappe.copy_doc(self.globalTestRecords["Quotation"][0])
quotation.transaction_date = nowdate()
quotation.valid_till = add_months(quotation.transaction_date, 1)
quotation.insert()
@@ -105,7 +105,7 @@ class TestQuotation(IntegrationTestCase):
def test_make_sales_order_with_different_currency(self):
from erpnext.selling.doctype.quotation.quotation import make_sales_order
quotation = frappe.copy_doc(test_records[0])
quotation = frappe.copy_doc(self.globalTestRecords["Quotation"][0])
quotation.transaction_date = nowdate()
quotation.valid_till = add_months(quotation.transaction_date, 1)
quotation.insert()
@@ -125,7 +125,7 @@ class TestQuotation(IntegrationTestCase):
def test_make_sales_order(self):
from erpnext.selling.doctype.quotation.quotation import make_sales_order
quotation = frappe.copy_doc(test_records[0])
quotation = frappe.copy_doc(self.globalTestRecords["Quotation"][0])
quotation.transaction_date = nowdate()
quotation.valid_till = add_months(quotation.transaction_date, 1)
quotation.insert()
@@ -149,7 +149,7 @@ class TestQuotation(IntegrationTestCase):
def test_make_sales_order_with_terms(self):
from erpnext.selling.doctype.quotation.quotation import make_sales_order
quotation = frappe.copy_doc(test_records[0])
quotation = frappe.copy_doc(self.globalTestRecords["Quotation"][0])
quotation.transaction_date = nowdate()
quotation.valid_till = add_months(quotation.transaction_date, 1)
quotation.update({"payment_terms_template": "_Test Payment Term Template"})
@@ -189,7 +189,7 @@ class TestQuotation(IntegrationTestCase):
)
def test_valid_till_before_transaction_date(self):
quotation = frappe.copy_doc(test_records[0])
quotation = frappe.copy_doc(self.globalTestRecords["Quotation"][0])
quotation.valid_till = add_days(quotation.transaction_date, -1)
self.assertRaises(frappe.ValidationError, quotation.validate)
@@ -198,7 +198,7 @@ class TestQuotation(IntegrationTestCase):
frappe.db.set_single_value("Selling Settings", "allow_sales_order_creation_for_expired_quotation", 0)
quotation = frappe.copy_doc(test_records[0])
quotation = frappe.copy_doc(self.globalTestRecords["Quotation"][0])
quotation.valid_till = add_days(nowdate(), -1)
quotation.insert()
quotation.submit()
@@ -218,11 +218,13 @@ class TestQuotation(IntegrationTestCase):
rate_with_margin = flt((1500 * 18.75) / 100 + 1500)
test_records[0]["items"][0]["price_list_rate"] = 1500
test_records[0]["items"][0]["margin_type"] = "Percentage"
test_records[0]["items"][0]["margin_rate_or_amount"] = 18.75
test_record = dict(self.globalTestRecords["Quotation"][0])
quotation = frappe.copy_doc(test_records[0])
test_record["items"][0]["price_list_rate"] = 1500
test_record["items"][0]["margin_type"] = "Percentage"
test_record["items"][0]["margin_rate_or_amount"] = 18.75
quotation = frappe.copy_doc(test_record)
quotation.transaction_date = nowdate()
quotation.valid_till = add_months(quotation.transaction_date, 1)
quotation.insert()
@@ -737,9 +739,6 @@ class TestQuotation(IntegrationTestCase):
item_doc.save()
test_records = frappe.get_test_records("Quotation")
def enable_calculate_bundle_price(enable=1):
selling_settings = frappe.get_doc("Selling Settings")
selling_settings.editable_bundle_item_rates = enable