Aditya Hase | f3c22f3 | 2019-01-22 18:22:20 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 2 | import unittest |
| 3 | |
| 4 | import frappe |
| 5 | from erpnext import encode_company_abbr |
| 6 | from six.moves import range |
| 7 | |
| 8 | test_records = frappe.get_test_records('Company') |
| 9 | |
tundebabzy | a109141 | 2017-05-19 07:12:45 +0100 | [diff] [blame] | 10 | class 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 | ) |