[bean] [mandatory] fixes in test cases

This commit is contained in:
Anand Doshi
2013-07-08 18:50:45 +05:30
parent 2862c9e1df
commit 4ee647e84c
20 changed files with 75 additions and 33 deletions

View File

@@ -100,7 +100,17 @@ class DocType(SellingController):
@webnotes.whitelist()
def make_customer(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
def set_missing_values(source, target):
if source.doc.company_name:
target[0].customer_type = "Company"
target[0].customer_name = source.doc.company_name
else:
target[0].customer_type = "Individual"
target[0].customer_name = source.doc.lead_name
target[0].customer_group = webnotes.conn.get_default("customer_group")
doclist = get_mapped_doclist("Lead", source_name,
{"Lead": {
"doctype": "Customer",
@@ -110,7 +120,7 @@ def make_customer(source_name, target_doclist=None):
"contact_no": "phone_1",
"fax": "fax_1"
}
}}, target_doclist)
}}, target_doclist, set_missing_values)
return [d.fields for d in doclist]

View File

@@ -2,7 +2,7 @@ from __future__ import unicode_literals
test_records = [
[{"doctype":"Lead", "lead_name": "_Test Lead", "status":"Open",
"email_id":"test_lead@example.com"}],
"email_id":"test_lead@example.com", "territory": "_Test Territory"}],
[{"doctype":"Lead", "lead_name": "_Test Lead 1", "status":"Open",
"email_id":"test_lead1@example.com"}],
[{"doctype":"Lead", "lead_name": "_Test Lead 2", "status":"Contacted",
@@ -21,6 +21,7 @@ class TestLead(unittest.TestCase):
customer = make_customer("_T-Lead-00001")
self.assertEquals(customer[0]["doctype"], "Customer")
self.assertEquals(customer[0]["lead_name"], "_T-Lead-00001")
customer[0].customer_group = "_Test Customer Group"
webnotes.bean(customer).insert()