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