Skip to content

Commit

Permalink
test: updated test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
noahjacob committed Jul 2, 2021
1 parent 38f105e commit f90760b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
24 changes: 14 additions & 10 deletions erpnext/buying/doctype/supplier/test_supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

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 = {
Expand All @@ -23,15 +24,18 @@ def test_get_supplier_group_details(self):
}
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
Expand Down
36 changes: 20 additions & 16 deletions erpnext/selling/doctype/customer/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def tearDown(self):
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"
Expand All @@ -43,21 +44,24 @@ def test_get_customer_group_details(self):
}
doc.append("accounts", test_account_details)
doc.append("credit_limits", test_credit_limits)
doc.save()

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")

self.assertEqual(doc.accounts[0].company, "_Test Company")
self.assertEqual(doc.accounts[0].account, "Creditors - _TC")

self.assertEqual(doc.credit_limits[0].company, "_Test Company")
self.assertEqual(doc.credit_limits[0].credit_limit, 350000 )
doc.insert()

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(c_doc.accounts[0].company, "_Test Company")
self.assertEqual(c_doc.accounts[0].account, "Creditors - _TC")

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
Expand Down

0 comments on commit f90760b

Please sign in to comment.