blob: 43340ce37a56f43333df92ae1ec54332a1fdb29c [file] [log] [blame]
tundebabzya1091412017-05-19 07:12:45 +01001import unittest
2
3import frappe
4from erpnext import encode_company_abbr
5from six.moves import range
6
7test_records = frappe.get_test_records('Company')
8
tundebabzya1091412017-05-19 07:12:45 +01009class TestInit(unittest.TestCase):
10 def test_encode_company_abbr(self):
11 company = frappe.new_doc("Company")
12 company.company_name = "New from Existing Company For Test"
13 company.abbr = "NFECT"
14 company.default_currency = "INR"
15 company.save()
16
17 abbr = company.abbr
18
19 names = [
20 "Warehouse Name", "ERPNext Foundation India", "Gold - Member - {a}".format(a=abbr),
21 " - {a}".format(a=abbr), "ERPNext - Foundation - India",
22 "ERPNext Foundation India - {a}".format(a=abbr),
23 "No-Space-{a}".format(a=abbr), "- Warehouse"
24 ]
25
26 expected_names = [
27 "Warehouse Name - {a}".format(a=abbr), "ERPNext Foundation India - {a}".format(a=abbr),
28 "Gold - Member - {a}".format(a=abbr), " - {a}".format(a=abbr),
29 "ERPNext - Foundation - India - {a}".format(a=abbr),
30 "ERPNext Foundation India - {a}".format(a=abbr), "No-Space-{a} - {a}".format(a=abbr),
31 "- Warehouse - {a}".format(a=abbr)
32 ]
33
34 for i in range(len(names)):
35 enc_name = encode_company_abbr(names[i], company.name)
36 self.assertTrue(
37 enc_name == expected_names[i],
38 "{enc} is not same as {exp}".format(enc=enc_name, exp=expected_names[i])
39 )