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