You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.4 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2015 Antiun Ingenieria S.L. - Antonio Espinosa
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp.tests.common import TransactionCase
  5. class PartnerNamesOrder(TransactionCase):
  6. def order_set(self, order):
  7. return self.env['ir.config_parameter'].set_param(
  8. 'partner_names_order', order)
  9. def test_get_computed_name(self):
  10. lastname = u"García Lorca"
  11. firstname = u"Federico"
  12. cases = (
  13. ('last_first', u"García Lorca Federico"),
  14. ('last_first_comma', u"García Lorca, Federico"),
  15. ('first_last', u"Federico García Lorca"),
  16. )
  17. for order, name in cases:
  18. self.order_set(order)
  19. result = self.env['res.partner']._get_computed_name(
  20. lastname, firstname)
  21. self.assertEqual(result, name)
  22. def test_get_inverse_name(self):
  23. lastname = u"Flanker"
  24. firstname = u"Petër"
  25. cases = (
  26. ('last_first', u"Flanker Petër"),
  27. ('last_first_comma', u"Flanker, Petër"),
  28. ('first_last', u"Petër Flanker"),
  29. )
  30. for order, name in cases:
  31. self.order_set(order)
  32. result = self.env['res.partner']._get_inverse_name(name)
  33. self.assertEqual(result['lastname'], lastname)
  34. self.assertEqual(result['firstname'], firstname)