Browse Source

[ADD] firstname_display_name - python unit tests

pull/2/head
Yannick Vaucher 12 years ago
parent
commit
11cff5c971
  1. 5
      firstname_display_name_trigger/tests/__init__.py
  2. 31
      firstname_display_name_trigger/tests/test_display_name.py

5
firstname_display_name_trigger/tests/__init__.py

@ -0,0 +1,5 @@
import test_display_name
checks = [
test_display_name
]

31
firstname_display_name_trigger/tests/test_display_name.py

@ -0,0 +1,31 @@
import unittest2
import openerp.tests.common as common
class test_display_name(common.TransactionCase):
def setUp(self):
super(test_display_name,self).setUp()
cr, uid = self.cr, self.uid
self.res_partner = self.registry('res.partner')
def test_00_create_res_partner(self):
""" Test if the display name has been correctly set """
cr, uid = self.cr, self.uid
partner_id = self.res_partner.create(cr, uid, {'lastname': 'Lastname', 'firstname': 'Firstname', 'is_company': True})
partner_records = self.res_partner.browse(cr, uid, [partner_id])
p1 = partner_records[0]
self.assertEqual(p1.display_name, 'Lastname Firstname', 'Partner display_name incorect')
def test_01_res_partner_write_lastname(self):
""" Test if the display name has been correctly set """
cr, uid = self.cr, self.uid
partner_id = self.res_partner.create(cr, uid, {'lastname': 'Lastname', 'firstname': 'Firstname', 'is_company': True})
partner_records = self.res_partner.browse(cr, uid, [partner_id])
p1 = partner_records[0]
self.res_partner.write(cr, uid, partner_id, {'lastname': 'Last'})
self.assertEqual(p1.display_name, 'Last Firstname', 'Partner display_name incorect')
if __name__ == '__main__':
unittest2.main()
Loading…
Cancel
Save