mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
refactor(test): "Lead" test suite working locally
This commit is contained in:
@@ -11,14 +11,67 @@ from erpnext.crm.utils import get_linked_prospect
|
|||||||
|
|
||||||
|
|
||||||
class TestLead(IntegrationTestCase):
|
class TestLead(IntegrationTestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
cls.make_leads()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def make_leads(cls):
|
||||||
|
records = [
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead@example.com",
|
||||||
|
"lead_name": "_Test Lead",
|
||||||
|
"status": "Open",
|
||||||
|
"territory": "_Test Territory",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead1@example.com",
|
||||||
|
"lead_name": "_Test Lead 1",
|
||||||
|
"status": "Open",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead2@example.com",
|
||||||
|
"lead_name": "_Test Lead 2",
|
||||||
|
"status": "Lead",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead3@example.com",
|
||||||
|
"lead_name": "_Test Lead 3",
|
||||||
|
"status": "Converted",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Lead",
|
||||||
|
"email_id": "test_lead4@example.com",
|
||||||
|
"lead_name": "_Test Lead 4",
|
||||||
|
"company_name": "_Test Lead 4",
|
||||||
|
"status": "Open",
|
||||||
|
"naming_series": "_T-Lead-",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
cls.leads = []
|
||||||
|
for x in records:
|
||||||
|
if not frappe.db.exists("Lead", {"email_id": x.get("email_id")}):
|
||||||
|
cls.leads.append(frappe.get_doc(x).insert())
|
||||||
|
else:
|
||||||
|
cls.leads.append(frappe.get_doc("Lead", {"email_id": x.get("email_id")}))
|
||||||
|
|
||||||
def test_make_customer(self):
|
def test_make_customer(self):
|
||||||
from erpnext.crm.doctype.lead.lead import make_customer
|
from erpnext.crm.doctype.lead.lead import make_customer
|
||||||
|
|
||||||
frappe.delete_doc_if_exists("Customer", "_Test Lead")
|
frappe.delete_doc_if_exists("Customer", "_Test Lead")
|
||||||
|
|
||||||
customer = make_customer("_T-Lead-00001")
|
customer = make_customer(self.leads[0].name)
|
||||||
self.assertEqual(customer.doctype, "Customer")
|
self.assertEqual(customer.doctype, "Customer")
|
||||||
self.assertEqual(customer.lead_name, "_T-Lead-00001")
|
self.assertEqual(customer.lead_name, self.leads[0].name)
|
||||||
|
|
||||||
customer.company = "_Test Company"
|
customer.company = "_Test Company"
|
||||||
customer.customer_group = "_Test Customer Group"
|
customer.customer_group = "_Test Customer Group"
|
||||||
@@ -42,9 +95,9 @@ class TestLead(IntegrationTestCase):
|
|||||||
def test_make_customer_from_organization(self):
|
def test_make_customer_from_organization(self):
|
||||||
from erpnext.crm.doctype.lead.lead import make_customer
|
from erpnext.crm.doctype.lead.lead import make_customer
|
||||||
|
|
||||||
customer = make_customer("_T-Lead-00002")
|
customer = make_customer(self.leads[1].name)
|
||||||
self.assertEqual(customer.doctype, "Customer")
|
self.assertEqual(customer.doctype, "Customer")
|
||||||
self.assertEqual(customer.lead_name, "_T-Lead-00002")
|
self.assertEqual(customer.lead_name, self.leads[1].name)
|
||||||
|
|
||||||
customer.company = "_Test Company"
|
customer.company = "_Test Company"
|
||||||
customer.customer_group = "_Test Customer Group"
|
customer.customer_group = "_Test Customer Group"
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead@example.com",
|
|
||||||
"lead_name": "_Test Lead",
|
|
||||||
"status": "Open",
|
|
||||||
"territory": "_Test Territory"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead1@example.com",
|
|
||||||
"lead_name": "_Test Lead 1",
|
|
||||||
"status": "Open"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead2@example.com",
|
|
||||||
"lead_name": "_Test Lead 2",
|
|
||||||
"status": "Lead"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead3@example.com",
|
|
||||||
"lead_name": "_Test Lead 3",
|
|
||||||
"status": "Converted"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Lead",
|
|
||||||
"email_id": "test_lead4@example.com",
|
|
||||||
"lead_name": "_Test Lead 4",
|
|
||||||
"company_name": "_Test Lead 4",
|
|
||||||
"status": "Open"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Reference in New Issue
Block a user