refactor(test): make opportunity deterministic

This commit is contained in:
ruthra kumar
2025-11-13 13:14:20 +05:30
parent 3b5667c007
commit 0b2dbcf30c

View File

@@ -29,6 +29,7 @@ class TestOpportunity(ERPNextTestSuite):
"opportunity_from": "Lead",
"enquiry_type": "Sales",
"party_name": cls.leads[0].name,
"company": cls.companies[0].name,
"transaction_date": "2013-12-12",
"items": [
{"item_name": "Test Item", "description": "Some description", "qty": 5, "rate": 100}
@@ -55,7 +56,7 @@ class TestOpportunity(ERPNextTestSuite):
self.assertEqual(doc.status, "Quotation")
def test_make_new_lead_if_required(self):
opp_doc = make_opportunity_from_lead()
opp_doc = make_opportunity_from_lead(self.companies[0].name)
self.assertTrue(opp_doc.party_name)
self.assertEqual(opp_doc.opportunity_from, "Lead")
@@ -99,7 +100,7 @@ class TestOpportunity(ERPNextTestSuite):
create_communication(opp_doc.doctype, opp_doc.name, opp_doc.contact_email)
def make_opportunity_from_lead():
def make_opportunity_from_lead(company):
new_lead_email_id = f"new{random_string(5)}@example.com"
args = {
"doctype": "Opportunity",
@@ -107,6 +108,7 @@ def make_opportunity_from_lead():
"opportunity_type": "Sales",
"with_items": 0,
"transaction_date": today(),
"company": company,
}
# new lead should be created against the new.opportunity@example.com
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)