mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 10:11:20 +00:00
refactor(test): make opportunity deterministic
This commit is contained in:
@@ -29,6 +29,7 @@ class TestOpportunity(ERPNextTestSuite):
|
|||||||
"opportunity_from": "Lead",
|
"opportunity_from": "Lead",
|
||||||
"enquiry_type": "Sales",
|
"enquiry_type": "Sales",
|
||||||
"party_name": cls.leads[0].name,
|
"party_name": cls.leads[0].name,
|
||||||
|
"company": cls.companies[0].name,
|
||||||
"transaction_date": "2013-12-12",
|
"transaction_date": "2013-12-12",
|
||||||
"items": [
|
"items": [
|
||||||
{"item_name": "Test Item", "description": "Some description", "qty": 5, "rate": 100}
|
{"item_name": "Test Item", "description": "Some description", "qty": 5, "rate": 100}
|
||||||
@@ -55,7 +56,7 @@ class TestOpportunity(ERPNextTestSuite):
|
|||||||
self.assertEqual(doc.status, "Quotation")
|
self.assertEqual(doc.status, "Quotation")
|
||||||
|
|
||||||
def test_make_new_lead_if_required(self):
|
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.assertTrue(opp_doc.party_name)
|
||||||
self.assertEqual(opp_doc.opportunity_from, "Lead")
|
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)
|
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"
|
new_lead_email_id = f"new{random_string(5)}@example.com"
|
||||||
args = {
|
args = {
|
||||||
"doctype": "Opportunity",
|
"doctype": "Opportunity",
|
||||||
@@ -107,6 +108,7 @@ def make_opportunity_from_lead():
|
|||||||
"opportunity_type": "Sales",
|
"opportunity_type": "Sales",
|
||||||
"with_items": 0,
|
"with_items": 0,
|
||||||
"transaction_date": today(),
|
"transaction_date": today(),
|
||||||
|
"company": company,
|
||||||
}
|
}
|
||||||
# new lead should be created against the new.opportunity@example.com
|
# new lead should be created against the new.opportunity@example.com
|
||||||
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)
|
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user