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