[fix] tests
This commit is contained in:
parent
7c7b3c0ab4
commit
592104ef68
@ -26,7 +26,7 @@ class TestCustomer(unittest.TestCase):
|
||||
'selling_price_list': None,
|
||||
'customer_group': '_Test Customer Group',
|
||||
'contact_designation': None,
|
||||
'customer_address': '_Test Address-Office',
|
||||
'customer_address': '_Test Address for Customer-Office',
|
||||
'contact_department': None,
|
||||
'contact_email': 'test_contact_customer@example.com',
|
||||
'contact_mobile': None,
|
||||
@ -38,8 +38,28 @@ class TestCustomer(unittest.TestCase):
|
||||
'customer_name': '_Test Customer'
|
||||
}
|
||||
|
||||
make_test_records("Address")
|
||||
make_test_records("Contact")
|
||||
address = frappe.get_doc(dict(
|
||||
doctype='Address',
|
||||
address_title='_Test Address for Customer',
|
||||
address_type='Office',
|
||||
address_line1='Station Road',
|
||||
city='Mumbai',
|
||||
country='India',
|
||||
links = [dict(
|
||||
link_doctype='Customer',
|
||||
link_name='_Test Customer'
|
||||
)]
|
||||
)).insert()
|
||||
|
||||
contact = frappe.get_doc(dict(
|
||||
doctype='Contact',
|
||||
first_name='_Test Contact for _Test Customer',
|
||||
links = [dict(
|
||||
link_doctype='Customer',
|
||||
link_name='_Test Customer'
|
||||
)]
|
||||
)).insert()
|
||||
|
||||
frappe.db.set_value("Contact", "_Test Contact For _Test Customer-_Test Customer",
|
||||
"is_primary_contact", 1)
|
||||
|
||||
@ -48,6 +68,9 @@ class TestCustomer(unittest.TestCase):
|
||||
for key, value in to_check.iteritems():
|
||||
self.assertEquals(value, details.get(key))
|
||||
|
||||
address.delete()
|
||||
contact.delete()
|
||||
|
||||
def test_rename(self):
|
||||
for name in ("_Test Customer 1", "_Test Customer 1 Renamed"):
|
||||
frappe.db.sql("""delete from `tabCommunication`
|
||||
@ -117,6 +140,7 @@ class TestCustomer(unittest.TestCase):
|
||||
self.assertEquals(test_customer_1.customer_name, duplicate_customer.customer_name)
|
||||
|
||||
def get_customer_outstanding_amount(self):
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
outstanding_amt = get_customer_outstanding('_Test Customer', '_Test Company')
|
||||
|
||||
# If outstanding is negative make a transaction to get positive outstanding amount
|
||||
@ -124,7 +148,7 @@ class TestCustomer(unittest.TestCase):
|
||||
return outstanding_amt
|
||||
|
||||
item_qty = int((abs(outstanding_amt) + 200)/100)
|
||||
make_sales_order({'qty':item_qty})
|
||||
make_sales_order(qty=item_qty)
|
||||
return get_customer_outstanding('_Test Customer', '_Test Company')
|
||||
|
||||
def test_customer_credit_limit(self):
|
||||
@ -138,7 +162,7 @@ class TestCustomer(unittest.TestCase):
|
||||
|
||||
if outstanding_amt <= 0.0:
|
||||
item_qty = int((abs(outstanding_amt) + 200)/100)
|
||||
make_sales_order({'qty':item_qty})
|
||||
make_sales_order(qty=item_qty)
|
||||
|
||||
if credit_limit == 0.0:
|
||||
frappe.db.set_value("Customer", '_Test Customer', 'credit_limit', outstanding_amt - 50.0)
|
||||
@ -165,11 +189,7 @@ class TestCustomer(unittest.TestCase):
|
||||
self.assertRaises(frappe.ValidationError, make_sales_order)
|
||||
|
||||
def test_customer_credit_limit_on_change(self):
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
|
||||
outstanding_amt = self.get_customer_outstanding_amount()
|
||||
credit_limit = get_credit_limit('_Test Customer', '_Test Company')
|
||||
|
||||
customer = frappe.get_doc("Customer", '_Test Customer')
|
||||
customer.credit_limit = flt(outstanding_amt - 100)
|
||||
self.assertRaises(frappe.ValidationError, customer.save)
|
||||
|
@ -375,7 +375,7 @@ def get_address_docs(doctype=None, txt=None, filters=None, limit_start=0, limit_
|
||||
if not party:
|
||||
return []
|
||||
|
||||
address_names = frappe.db.get_all('Dyanamic Link', fields=('parent'),
|
||||
address_names = frappe.db.get_all('Dynamic Link', fields=('parent'),
|
||||
filters=dict(parenttype='Address', link_doctype=party.doctype, link_name=party.name))
|
||||
|
||||
out = []
|
||||
|
@ -25,8 +25,8 @@ class TestShoppingCart(unittest.TestCase):
|
||||
# test if lead is created and quotation with new lead is fetched
|
||||
quotation = _get_cart_quotation()
|
||||
self.assertEquals(quotation.quotation_to, "Customer")
|
||||
self.assertEquals(frappe.db.get_value("Contact", dict(contact_person="test_cart_user@example.com")),
|
||||
quotation.contact_name)
|
||||
self.assertEquals(frappe.db.get_value("Contact", dict(email_id="test_cart_user@example.com")),
|
||||
quotation.contact_person)
|
||||
self.assertEquals(quotation.lead, None)
|
||||
self.assertEquals(quotation.contact_email, frappe.session.user)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user