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.

47 lines
1.5 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. # -*- coding: utf-8 -*-
  2. import unittest2
  3. import openerp.tests.common as common
  4. class test_display_name(common.TransactionCase):
  5. def setUp(self):
  6. super(test_display_name, self).setUp()
  7. self.res_partner = self.registry('res.partner')
  8. def test_00_create_res_partner(self):
  9. """ Test if the display name has been correctly set """
  10. cr, uid = self.cr, self.uid
  11. partner_id = self.res_partner.create(cr, uid, {
  12. 'lastname': 'Lastname',
  13. 'firstname': 'Firstname',
  14. 'is_company': True,
  15. })
  16. partner_records = self.res_partner.browse(cr, uid, [partner_id])
  17. p1 = partner_records[0]
  18. self.assertEqual(
  19. p1.display_name,
  20. 'Lastname Firstname',
  21. 'Partner display_name incorrect'
  22. )
  23. def test_01_res_partner_write_lastname(self):
  24. """ Test if the display name has been correctly set """
  25. cr, uid = self.cr, self.uid
  26. partner_id = self.res_partner.create(cr, uid, {
  27. 'lastname': 'Lastname',
  28. 'firstname': 'Firstname',
  29. 'is_company': True
  30. })
  31. partner_records = self.res_partner.browse(cr, uid, [partner_id])
  32. p1 = partner_records[0]
  33. self.res_partner.write(cr, uid, partner_id, {'lastname': 'Last'})
  34. self.assertEqual(
  35. p1.display_name,
  36. 'Last Firstname',
  37. 'Partner display_name incorrect'
  38. )
  39. if __name__ == '__main__':
  40. unittest2.main()