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 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 7 | test_records = frappe.get_test_records("Company") |
| 8 | |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 9 | |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 10 | class TestInit(unittest.TestCase): |
| 11 | def test_encode_company_abbr(self): |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 12 | |
Ankush Menat | d7148ad | 2021-12-20 22:00:31 +0530 | [diff] [blame] | 13 | abbr = "NFECT" |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 14 | |
| 15 | names = [ |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 16 | "Warehouse Name", |
| 17 | "ERPNext Foundation India", |
| 18 | "Gold - Member - {a}".format(a=abbr), |
| 19 | " - {a}".format(a=abbr), |
| 20 | "ERPNext - Foundation - India", |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 21 | "ERPNext Foundation India - {a}".format(a=abbr), |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 22 | "No-Space-{a}".format(a=abbr), |
| 23 | "- Warehouse", |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 24 | ] |
| 25 | |
| 26 | expected_names = [ |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 27 | "Warehouse Name - {a}".format(a=abbr), |
| 28 | "ERPNext Foundation India - {a}".format(a=abbr), |
| 29 | "Gold - Member - {a}".format(a=abbr), |
| 30 | " - {a}".format(a=abbr), |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 31 | "ERPNext - Foundation - India - {a}".format(a=abbr), |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 32 | "ERPNext Foundation India - {a}".format(a=abbr), |
| 33 | "No-Space-{a} - {a}".format(a=abbr), |
| 34 | "- Warehouse - {a}".format(a=abbr), |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 35 | ] |
| 36 | |
| 37 | for i in range(len(names)): |
Ankush Menat | d7148ad | 2021-12-20 22:00:31 +0530 | [diff] [blame] | 38 | enc_name = encode_company_abbr(names[i], abbr=abbr) |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 39 | self.assertTrue( |
| 40 | enc_name == expected_names[i], |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 41 | "{enc} is not same as {exp}".format(enc=enc_name, exp=expected_names[i]), |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 42 | ) |