adds test case

This commit is contained in:
tunde 2017-06-22 17:34:54 +01:00
parent dcd54209fc
commit 94500fd17b

View File

@ -3,8 +3,10 @@
# See license.txt
from __future__ import unicode_literals
import frappe
import unittest
import frappe
from erpnext.templates.pages.rfq import check_supplier_has_docname_access
from frappe.utils import nowdate
class TestRequestforQuotation(unittest.TestCase):
@ -28,6 +30,30 @@ class TestRequestforQuotation(unittest.TestCase):
self.assertEquals(sq1.get('items')[0].item_code, "_Test Item")
self.assertEquals(sq1.get('items')[0].qty, 5)
def test_make_supplier_quotation_with_special_characters(self):
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import make_supplier_quotation
frappe.delete_doc_if_exists("Supplier", "_Test Supplier '1", force=1)
supplier = frappe.new_doc("Supplier")
supplier.supplier_name = "_Test Supplier '1"
supplier.supplier_type = "_Test Supplier Type"
supplier.insert()
rfq = make_request_for_quotation(supplier_wt_appos)
sq = make_supplier_quotation(rfq.name, supplier_wt_appos[0].get("supplier"))
sq.submit()
frappe.form_dict.name = rfq.name
self.assertEqual(
check_supplier_has_docname_access(supplier_wt_appos[0].get('supplier')),
True
)
# reset form_dict
frappe.form_dict.name = None
def test_make_supplier_quotation_from_portal(self):
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import create_supplier_quotation
rfq = make_request_for_quotation()
@ -44,8 +70,11 @@ class TestRequestforQuotation(unittest.TestCase):
self.assertEquals(supplier_quotation_doc.get('items')[0].amount, 500)
def make_request_for_quotation():
supplier_data = get_supplier_data()
def make_request_for_quotation(supplier_data=None):
"""
:param supplier_data: List containing supplier data
"""
supplier_data = supplier_data if supplier_data else get_supplier_data()
rfq = frappe.new_doc('Request for Quotation')
rfq.transaction_date = nowdate()
rfq.status = 'Draft'
@ -77,3 +106,8 @@ def get_supplier_data():
"supplier": "_Test Supplier 1",
"supplier_name": "_Test Supplier 1"
}]
supplier_wt_appos = [{
"supplier": "_Test Supplier '1",
"supplier_name": "_Test Supplier '1",
}]