[tests] fixed for shopping cart

This commit is contained in:
Rushabh Mehta 2017-01-17 17:57:19 +05:30
parent 7385b73449
commit 982be9f11b
4 changed files with 56 additions and 28 deletions

View File

@ -10,6 +10,7 @@ from frappe.test_runner import make_test_records
from erpnext.exceptions import PartyFrozen, PartyDisabled
from frappe.utils import flt
from erpnext.selling.doctype.customer.customer import get_credit_limit, get_customer_outstanding
from erpnext.tests.utils import create_test_contact_and_address
test_ignore = ["Price List"]
@ -47,31 +48,9 @@ class TestCustomer(unittest.TestCase):
'customer_name': '_Test Customer'
}
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()
create_test_contact_and_address()
contact = frappe.get_doc(dict(
doctype='Contact',
email_id='test_contact_customer@example.com',
phone='+91 0000000000',
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",
frappe.db.set_value("Contact", "_Test Contact for _Test Customer-_Test Customer",
"is_primary_contact", 1)
details = get_party_details("_Test Customer")

View File

@ -23,6 +23,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Enable Shopping Cart",
"length": 0,
"no_copy": 0,
@ -49,6 +50,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -74,6 +76,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Company",
"length": 0,
"no_copy": 0,
@ -94,6 +97,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Prices will not be shown if Price List is not set",
"fieldname": "price_list",
"fieldtype": "Link",
"hidden": 0,
@ -101,6 +105,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Price List",
"length": 0,
"no_copy": 0,
@ -112,7 +117,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@ -129,6 +134,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -155,6 +161,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Customer Group",
"length": 0,
"no_copy": 0,
@ -182,6 +189,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Quotation Series",
"length": 0,
"no_copy": 0,
@ -209,6 +217,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Checkout Settings",
"length": 0,
"no_copy": 0,
@ -236,6 +245,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Enable Checkout",
"length": 0,
"no_copy": 0,
@ -265,6 +275,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Payment Success Url",
"length": 0,
"no_copy": 0,
@ -293,6 +304,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -319,6 +331,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Payment Gateway Account",
"length": 0,
"no_copy": 0,
@ -347,7 +360,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2016-11-03 16:10:33.956822",
"modified": "2017-01-17 05:30:29.333104",
"modified_by": "Administrator",
"module": "Shopping Cart",
"name": "Shopping Cart Settings",
@ -379,5 +392,6 @@
"read_only": 0,
"read_only_onload": 0,
"sort_order": "ASC",
"track_changes": 0,
"track_seen": 0
}

View File

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import unittest
import frappe
from erpnext.shopping_cart.cart import _get_cart_quotation, update_cart, get_party
from erpnext.tests.utils import create_test_contact_and_address
class TestShoppingCart(unittest.TestCase):
"""
@ -25,8 +26,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(email_id="test_cart_user@example.com")),
quotation.contact_person)
self.assertEquals(quotation.contact_person,
frappe.db.get_value("Contact", dict(email_id="test_cart_user@example.com")))
self.assertEquals(quotation.lead, None)
self.assertEquals(quotation.contact_email, frappe.session.user)
@ -184,6 +185,7 @@ class TestShoppingCart(unittest.TestCase):
frappe.set_user("test_cart_user@example.com")
def login_as_customer(self):
create_test_contact_and_address()
self.create_user_if_not_exists("test_contact_customer@example.com",
"_Test Contact For _Test Customer")
frappe.set_user("test_contact_customer@example.com")

33
erpnext/tests/utils.py Normal file
View File

@ -0,0 +1,33 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def create_test_contact_and_address():
if not frappe.db.exists('Address', '_Test Address for Customer-Office'):
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()
if not frappe.db.exists('Contact', '_Test Contact for _Test Customer-_Test Customer'):
frappe.get_doc(dict(
doctype='Contact',
email_id='test_contact_customer@example.com',
phone='+91 0000000000',
first_name='_Test Contact for _Test Customer',
links = [dict(
link_doctype='Customer',
link_name='_Test Customer'
)]
)).insert()