2017-05-19 06:12:45 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
import frappe
|
|
|
|
|
|
|
|
from erpnext import encode_company_abbr
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2017-05-19 06:12:45 +00:00
|
|
|
test_records = frappe.get_test_records('Company')
|
|
|
|
|
|
|
|
class TestInit(unittest.TestCase):
|
|
|
|
def test_encode_company_abbr(self):
|
|
|
|
|
2021-12-20 16:30:31 +00:00
|
|
|
abbr = "NFECT"
|
2017-05-19 06:12:45 +00:00
|
|
|
|
|
|
|
names = [
|
|
|
|
"Warehouse Name", "ERPNext Foundation India", "Gold - Member - {a}".format(a=abbr),
|
|
|
|
" - {a}".format(a=abbr), "ERPNext - Foundation - India",
|
|
|
|
"ERPNext Foundation India - {a}".format(a=abbr),
|
|
|
|
"No-Space-{a}".format(a=abbr), "- Warehouse"
|
|
|
|
]
|
|
|
|
|
|
|
|
expected_names = [
|
|
|
|
"Warehouse Name - {a}".format(a=abbr), "ERPNext Foundation India - {a}".format(a=abbr),
|
|
|
|
"Gold - Member - {a}".format(a=abbr), " - {a}".format(a=abbr),
|
|
|
|
"ERPNext - Foundation - India - {a}".format(a=abbr),
|
|
|
|
"ERPNext Foundation India - {a}".format(a=abbr), "No-Space-{a} - {a}".format(a=abbr),
|
|
|
|
"- Warehouse - {a}".format(a=abbr)
|
|
|
|
]
|
|
|
|
|
|
|
|
for i in range(len(names)):
|
2021-12-20 16:30:31 +00:00
|
|
|
enc_name = encode_company_abbr(names[i], abbr=abbr)
|
2017-05-19 06:12:45 +00:00
|
|
|
self.assertTrue(
|
|
|
|
enc_name == expected_names[i],
|
|
|
|
"{enc} is not same as {exp}".format(enc=enc_name, exp=expected_names[i])
|
|
|
|
)
|