test: updated test cases

This commit is contained in:
Noah Jacob 2021-07-02 19:35:50 +05:30
parent fedee0e8da
commit dd0a8f20e2
2 changed files with 31 additions and 23 deletions

View File

@ -14,7 +14,8 @@ test_records = frappe.get_test_records('Supplier')
class TestSupplier(unittest.TestCase):
def test_get_supplier_group_details(self):
doc = frappe.get_doc("Supplier Group", "Local")
doc = frappe.new_doc("Supplier Group")
doc.supplier_group_name = "_Testing Supplier Group"
doc.payment_terms = "_Test Payment Term Template 3"
doc.accounts = []
test_account_details = {
@ -23,15 +24,18 @@ class TestSupplier(unittest.TestCase):
}
doc.append("accounts", test_account_details)
doc.save()
doc = frappe.get_doc("Supplier", "_Test Supplier")
doc.supplier_group = "Local"
doc.payment_terms = ""
doc.accounts = []
doc.save()
doc.get_supplier_group_details()
self.assertEqual(doc.payment_terms, "_Test Payment Term Template 3")
self.assertEqual(doc.accounts[0].company, "_Test Company")
self.assertEqual(doc.accounts[0].account, "Creditors - _TC")
s_doc = frappe.new_doc("Supplier")
s_doc.supplier_name = "Testing Supplier"
s_doc.supplier_group = "_Testing Supplier Group"
s_doc.payment_terms = ""
s_doc.accounts = []
s_doc.insert()
s_doc.get_supplier_group_details()
self.assertEqual(s_doc.payment_terms, "_Test Payment Term Template 3")
self.assertEqual(s_doc.accounts[0].company, "_Test Company")
self.assertEqual(s_doc.accounts[0].account, "Creditors - _TC")
s_doc.delete()
doc.delete()
def test_supplier_default_payment_terms(self):
# Payment Term based on Days after invoice date

View File

@ -28,7 +28,8 @@ class TestCustomer(unittest.TestCase):
set_credit_limit('_Test Customer', '_Test Company', 0)
def test_get_customer_group_details(self):
doc = frappe.get_doc("Customer Group", "Commercial")
doc = frappe.new_doc("Customer Group")
doc.customer_group_name = "_Testing Customer Group"
doc.payment_terms = "_Test Payment Term Template 3"
doc.accounts = []
doc.default_price_list = "Standard Buying"
@ -43,21 +44,24 @@ class TestCustomer(unittest.TestCase):
}
doc.append("accounts", test_account_details)
doc.append("credit_limits", test_credit_limits)
doc.save()
doc.insert()
doc = frappe.get_doc("Customer", "_Test Customer")
doc.customer_group = "Commercial"
doc.payment_terms = doc.default_price_list = ""
doc.accounts = doc.credit_limits= []
doc.save()
doc.get_customer_group_details()
self.assertEqual(doc.payment_terms, "_Test Payment Term Template 3")
c_doc = frappe.new_doc("Customer")
c_doc.customer_name = "Testing Customer"
c_doc.customer_group = "_Testing Customer Group"
c_doc.payment_terms = c_doc.default_price_list = ""
c_doc.accounts = c_doc.credit_limits= []
c_doc.insert()
c_doc.get_customer_group_details()
self.assertEqual(c_doc.payment_terms, "_Test Payment Term Template 3")
self.assertEqual(doc.accounts[0].company, "_Test Company")
self.assertEqual(doc.accounts[0].account, "Creditors - _TC")
self.assertEqual(c_doc.accounts[0].company, "_Test Company")
self.assertEqual(c_doc.accounts[0].account, "Creditors - _TC")
self.assertEqual(doc.credit_limits[0].company, "_Test Company")
self.assertEqual(doc.credit_limits[0].credit_limit, 350000 )
self.assertEqual(c_doc.credit_limits[0].company, "_Test Company")
self.assertEqual(c_doc.credit_limits[0].credit_limit, 350000)
c_doc.delete()
doc.delete()
def test_party_details(self):
from erpnext.accounts.party import get_party_details