blob: 6fbfbf46899c70ff3e9fe431a2a057030a91734e [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
Ankush Menat494bd9e2022-03-28 18:52:46 +05307test_records = frappe.get_test_records("Company")
8
tundebabzya1091412017-05-19 07:12:45 +01009
tundebabzya1091412017-05-19 07:12:45 +010010class TestInit(unittest.TestCase):
11 def test_encode_company_abbr(self):
tundebabzya1091412017-05-19 07:12:45 +010012
Ankush Menatd7148ad2021-12-20 22:00:31 +053013 abbr = "NFECT"
tundebabzya1091412017-05-19 07:12:45 +010014
15 names = [
Ankush Menat494bd9e2022-03-28 18:52:46 +053016 "Warehouse Name",
17 "ERPNext Foundation India",
18 "Gold - Member - {a}".format(a=abbr),
19 " - {a}".format(a=abbr),
20 "ERPNext - Foundation - India",
tundebabzya1091412017-05-19 07:12:45 +010021 "ERPNext Foundation India - {a}".format(a=abbr),
Ankush Menat494bd9e2022-03-28 18:52:46 +053022 "No-Space-{a}".format(a=abbr),
23 "- Warehouse",
tundebabzya1091412017-05-19 07:12:45 +010024 ]
25
26 expected_names = [
Ankush Menat494bd9e2022-03-28 18:52:46 +053027 "Warehouse Name - {a}".format(a=abbr),
28 "ERPNext Foundation India - {a}".format(a=abbr),
29 "Gold - Member - {a}".format(a=abbr),
30 " - {a}".format(a=abbr),
tundebabzya1091412017-05-19 07:12:45 +010031 "ERPNext - Foundation - India - {a}".format(a=abbr),
Ankush Menat494bd9e2022-03-28 18:52:46 +053032 "ERPNext Foundation India - {a}".format(a=abbr),
33 "No-Space-{a} - {a}".format(a=abbr),
34 "- Warehouse - {a}".format(a=abbr),
tundebabzya1091412017-05-19 07:12:45 +010035 ]
36
37 for i in range(len(names)):
Ankush Menatd7148ad2021-12-20 22:00:31 +053038 enc_name = encode_company_abbr(names[i], abbr=abbr)
tundebabzya1091412017-05-19 07:12:45 +010039 self.assertTrue(
40 enc_name == expected_names[i],
Ankush Menat494bd9e2022-03-28 18:52:46 +053041 "{enc} is not same as {exp}".format(enc=enc_name, exp=expected_names[i]),
tundebabzya1091412017-05-19 07:12:45 +010042 )