tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 1 | import unittest |
| 2 | |
| 3 | import frappe |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 4 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 5 | from erpnext import encode_company_abbr |
| 6 | |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 7 | test_records = frappe.get_test_records('Company') |
| 8 | |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 9 | class TestInit(unittest.TestCase): |
| 10 | def test_encode_company_abbr(self): |
| 11 | company = frappe.new_doc("Company") |
| 12 | company.company_name = "New from Existing Company For Test" |
| 13 | company.abbr = "NFECT" |
| 14 | company.default_currency = "INR" |
| 15 | company.save() |
| 16 | |
| 17 | abbr = company.abbr |
| 18 | |
| 19 | names = [ |
| 20 | "Warehouse Name", "ERPNext Foundation India", "Gold - Member - {a}".format(a=abbr), |
| 21 | " - {a}".format(a=abbr), "ERPNext - Foundation - India", |
| 22 | "ERPNext Foundation India - {a}".format(a=abbr), |
| 23 | "No-Space-{a}".format(a=abbr), "- Warehouse" |
| 24 | ] |
| 25 | |
| 26 | expected_names = [ |
| 27 | "Warehouse Name - {a}".format(a=abbr), "ERPNext Foundation India - {a}".format(a=abbr), |
| 28 | "Gold - Member - {a}".format(a=abbr), " - {a}".format(a=abbr), |
| 29 | "ERPNext - Foundation - India - {a}".format(a=abbr), |
| 30 | "ERPNext Foundation India - {a}".format(a=abbr), "No-Space-{a} - {a}".format(a=abbr), |
| 31 | "- Warehouse - {a}".format(a=abbr) |
| 32 | ] |
| 33 | |
| 34 | for i in range(len(names)): |
| 35 | enc_name = encode_company_abbr(names[i], company.name) |
| 36 | self.assertTrue( |
| 37 | enc_name == expected_names[i], |
| 38 | "{enc} is not same as {exp}".format(enc=enc_name, exp=expected_names[i]) |
| 39 | ) |