blob: 61849726efe45ff73ee344557ab97dbc82668908 [file] [log] [blame]
tundebabzya1091412017-05-19 07:12:45 +01001import unittest
2
3import frappe
tundebabzya1091412017-05-19 07:12:45 +01004
Chillar Anand915b3432021-09-02 16:44:59 +05305from erpnext import encode_company_abbr
6
tundebabzya1091412017-05-19 07:12:45 +01007test_records = frappe.get_test_records('Company')
8
tundebabzya1091412017-05-19 07:12:45 +01009class TestInit(unittest.TestCase):
10 def test_encode_company_abbr(self):
tundebabzya1091412017-05-19 07:12:45 +010011
Ankush Menatd7148ad2021-12-20 22:00:31 +053012 abbr = "NFECT"
tundebabzya1091412017-05-19 07:12:45 +010013
14 names = [
15 "Warehouse Name", "ERPNext Foundation India", "Gold - Member - {a}".format(a=abbr),
16 " - {a}".format(a=abbr), "ERPNext - Foundation - India",
17 "ERPNext Foundation India - {a}".format(a=abbr),
18 "No-Space-{a}".format(a=abbr), "- Warehouse"
19 ]
20
21 expected_names = [
22 "Warehouse Name - {a}".format(a=abbr), "ERPNext Foundation India - {a}".format(a=abbr),
23 "Gold - Member - {a}".format(a=abbr), " - {a}".format(a=abbr),
24 "ERPNext - Foundation - India - {a}".format(a=abbr),
25 "ERPNext Foundation India - {a}".format(a=abbr), "No-Space-{a} - {a}".format(a=abbr),
26 "- Warehouse - {a}".format(a=abbr)
27 ]
28
29 for i in range(len(names)):
Ankush Menatd7148ad2021-12-20 22:00:31 +053030 enc_name = encode_company_abbr(names[i], abbr=abbr)
tundebabzya1091412017-05-19 07:12:45 +010031 self.assertTrue(
32 enc_name == expected_names[i],
33 "{enc} is not same as {exp}".format(enc=enc_name, exp=expected_names[i])
34 )