[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()

View File

@@ -22,9 +22,7 @@ class TestQuotation(unittest.TestCase):
self.assertEquals(sales_order[0]["customer"], "_Test Customer")
sales_order[0]["delivery_date"] = "2014-01-01"
webnotes.print_messages = True
sales_order[0]["naming_series"] = "_T-Quotation-"
webnotes.bean(sales_order).insert()
@@ -34,6 +32,7 @@ test_records = [
"company": "_Test Company",
"conversion_rate": 1.0,
"currency": "INR",
"quotation_to": "Customer",
"customer": "_Test Customer",
"customer_name": "_Test Customer",
"customer_group": "_Test Customer Group",

View File

@@ -290,6 +290,7 @@ test_records = [
"transaction_date": "2013-02-21",
"grand_total": 1000.0,
"grand_total_export": 1000.0,
"naming_series": "_T-Sales Order-"
},
{
"description": "CPU",