Browse Source

[FIX] some tests failed if user's language is not english

[CHG] improve some assertions
pull/2/head
Olivier LAURENT 11 years ago
parent
commit
be00f74797
  1. 16
      partner_firstname/i18n/de.po
  2. 6
      partner_firstname/i18n/en.po
  3. 16
      partner_firstname/i18n/fr.po
  4. 16
      partner_firstname/i18n/nl.po
  5. 6
      partner_firstname/i18n/partner_firstname.pot
  6. 77
      partner_firstname/tests/test_partner_firstname.py

16
partner_firstname/i18n/de.po

@ -16,8 +16,12 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: partner_firstname #. module: partner_firstname
#: code:addons/partner_firstname/partner.py:76
#: code:addons/partner_firstname/partner.py:81
#: code:addons/partner_firstname/res_user.py:35 #: code:addons/partner_firstname/res_user.py:35
#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
#, python-format #, python-format
msgid "%s (copy)" msgid "%s (copy)"
msgstr "%s (kopie)" msgstr "%s (kopie)"
@ -27,16 +31,16 @@ msgstr "%s (kopie)"
msgid "Users" msgid "Users"
msgstr "Benutzer" msgstr "Benutzer"
#. module: partner_firstname
#: field:res.partner,lastname:0
msgid "Lastname"
msgstr "Name"
#. module: partner_firstname #. module: partner_firstname
#: field:res.partner,firstname:0 #: field:res.partner,firstname:0
msgid "Firstname" msgid "Firstname"
msgstr "Vorname" msgstr "Vorname"
#. module: partner_firstname
#: field:res.partner,lastname:0
msgid "Lastname"
msgstr "Name"
#. module: partner_firstname #. module: partner_firstname
#: view:res.partner:0 #: view:res.partner:0
msgid "Is a Company?" msgid "Is a Company?"

6
partner_firstname/i18n/en.po

@ -16,8 +16,12 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: partner_firstname #. module: partner_firstname
#: code:addons/partner_firstname/partner.py:76
#: code:addons/partner_firstname/partner.py:81
#: code:addons/partner_firstname/res_user.py:35 #: code:addons/partner_firstname/res_user.py:35
#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
#, python-format #, python-format
msgid "%s (copy)" msgid "%s (copy)"
msgstr "%s (copy)" msgstr "%s (copy)"

16
partner_firstname/i18n/fr.po

@ -16,8 +16,12 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: partner_firstname #. module: partner_firstname
#: code:addons/partner_firstname/partner.py:76
#: code:addons/partner_firstname/partner.py:81
#: code:addons/partner_firstname/res_user.py:35 #: code:addons/partner_firstname/res_user.py:35
#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
#, python-format #, python-format
msgid "%s (copy)" msgid "%s (copy)"
msgstr "%s (copie)" msgstr "%s (copie)"
@ -27,16 +31,16 @@ msgstr "%s (copie)"
msgid "Users" msgid "Users"
msgstr "Utilisateur" msgstr "Utilisateur"
#. module: partner_firstname
#: field:res.partner,lastname:0
msgid "Lastname"
msgstr "Nom"
#. module: partner_firstname #. module: partner_firstname
#: field:res.partner,firstname:0 #: field:res.partner,firstname:0
msgid "Firstname" msgid "Firstname"
msgstr "Prénom" msgstr "Prénom"
#. module: partner_firstname
#: field:res.partner,lastname:0
msgid "Lastname"
msgstr "Nom de famille"
#. module: partner_firstname #. module: partner_firstname
#: view:res.partner:0 #: view:res.partner:0
msgid "Is a Company?" msgid "Is a Company?"

16
partner_firstname/i18n/nl.po

@ -16,8 +16,12 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: partner_firstname #. module: partner_firstname
#: code:addons/partner_firstname/partner.py:76
#: code:addons/partner_firstname/partner.py:81
#: code:addons/partner_firstname/res_user.py:35 #: code:addons/partner_firstname/res_user.py:35
#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
#, python-format #, python-format
msgid "%s (copy)" msgid "%s (copy)"
msgstr "%s (kopie)" msgstr "%s (kopie)"
@ -27,16 +31,16 @@ msgstr "%s (kopie)"
msgid "Users" msgid "Users"
msgstr "Gebruikers" msgstr "Gebruikers"
#. module: partner_firstname
#: field:res.partner,lastname:0
msgid "Lastname"
msgstr "Achternaam"
#. module: partner_firstname #. module: partner_firstname
#: field:res.partner,firstname:0 #: field:res.partner,firstname:0
msgid "Firstname" msgid "Firstname"
msgstr "Voornaam" msgstr "Voornaam"
#. module: partner_firstname
#: field:res.partner,lastname:0
msgid "Lastname"
msgstr "Achternaam"
#. module: partner_firstname #. module: partner_firstname
#: view:res.partner:0 #: view:res.partner:0
msgid "Is a Company?" msgid "Is a Company?"

6
partner_firstname/i18n/partner_firstname.pot

@ -16,8 +16,12 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: partner_firstname #. module: partner_firstname
#: code:addons/partner_firstname/partner.py:76
#: code:addons/partner_firstname/partner.py:81
#: code:addons/partner_firstname/res_user.py:35 #: code:addons/partner_firstname/res_user.py:35
#: code:addons/partner_firstname/tests/test_partner_firstname.py:56
#: code:addons/partner_firstname/tests/test_partner_firstname.py:57
#: code:addons/partner_firstname/tests/test_partner_firstname.py:71
#: code:addons/partner_firstname/tests/test_partner_firstname.py:72
#, python-format #, python-format
msgid "%s (copy)" msgid "%s (copy)"
msgstr "" msgstr ""

77
partner_firstname/tests/test_partner_firstname.py

@ -29,11 +29,14 @@
############################################################################## ##############################################################################
import openerp.tests.common as common import openerp.tests.common as common
from openerp.tools.translate import _
class test_partner_firstname(common.TransactionCase): class test_partner_firstname(common.TransactionCase):
def setUp(self): def setUp(self):
super(test_partner_firstname, self).setUp() super(test_partner_firstname, self).setUp()
self.registry('ir.model').clear_caches() self.registry('ir.model').clear_caches()
self.registry('ir.model.data').clear_caches() self.registry('ir.model.data').clear_caches()
@ -42,53 +45,59 @@ class test_partner_firstname(common.TransactionCase):
self.fields_partner = {'lastname': 'lastname', 'firstname': 'firstname'} self.fields_partner = {'lastname': 'lastname', 'firstname': 'firstname'}
self.fields_user = {'name': 'lastname', 'login': 'v5Ue4Tql0Pm67KX05g25A'} self.fields_user = {'name': 'lastname', 'login': 'v5Ue4Tql0Pm67KX05g25A'}
self.context = self.user_model.context_get(self.cr, self.uid)
def test_copy_partner(self): def test_copy_partner(self):
cr, uid = self.cr, self.uid
res_id = self.partner_model.create(cr, uid, self.fields_partner, context={})
res_id = self.partner_model.copy(cr, uid, res_id, default={}, context={})
vals = self.partner_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context={})[0]
self.assertEqual(vals['name'] == "lastname (copy) firstname" and
vals['lastname'] == 'lastname (copy)' and
vals['firstname'] == 'firstname', True, 'Copy of the partner failed with wrong values')
cr, uid, context = self.cr, self.uid, self.context
res_id = self.partner_model.create(cr, uid, self.fields_partner, context=context)
res_id = self.partner_model.copy(cr, uid, res_id, default={}, context=context)
vals = self.partner_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context=context)[0]
self.assertEqual(vals['name'], _('%s (copy)') % 'lastname' + " firstname", 'Copy of the partner failed with wrong name')
self.assertEqual(vals['lastname'], _('%s (copy)') % 'lastname', 'Copy of the partner failed with wrong lastname')
self.assertEqual(vals['firstname'], 'firstname', 'Copy of the partner failed with wrong firstname')
def test_copy_user(self): def test_copy_user(self):
cr, uid = self.cr, self.uid
cr, uid, context = self.cr, self.uid, self.context
# create a user # create a user
res_id = self.user_model.create(cr, uid, self.fields_user, context={})
res_id = self.user_model.create(cr, uid, self.fields_user, context=context)
# get the related partner id and add it a firstname # get the related partner id and add it a firstname
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context={})[0]
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname':'firstname'}, context={})
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context=context)[0]
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname':'firstname'}, context=context)
# copy the user and compare result # copy the user and compare result
res_id = self.user_model.copy(cr, uid, res_id, default={}, context={})
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context={})[0]
self.assertEqual(vals['name'] == "lastname (copy) firstname" and
vals['lastname'] == 'lastname (copy)' and
vals['firstname'] == 'firstname', True, 'Copy of the user failed with wrong values')
res_id = self.user_model.copy(cr, uid, res_id, default={}, context=context)
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context=context)[0]
self.assertEqual(vals['name'], _('%s (copy)') % 'lastname' + ' firstname', 'Copy of the user failed with wrong name')
self.assertEqual(vals['lastname'], _('%s (copy)') % 'lastname', 'Copy of the user failed with wrong lastname')
self.assertEqual(vals['firstname'], 'firstname', 'Copy of the user failed with wrong firstname')
def test_update_user_lastname(self): def test_update_user_lastname(self):
cr, uid = self.cr, self.uid
cr, uid, context = self.cr, self.uid, self.context
# create a user # create a user
res_id = self.user_model.create(cr, uid, self.fields_user, context={})
res_id = self.user_model.create(cr, uid, self.fields_user, context=context)
# get the related partner id and add it a firstname # get the related partner id and add it a firstname
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context={})[0]
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname':'firstname'}, context={})
self.user_model.write(cr, uid, res_id, {'name': 'change firstname'}, context={})
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context={})[0]
self.assertEqual(vals['name'] == "change firstname" and
vals['lastname'] == 'change' and
vals['firstname'] == 'firstname', True, 'Update of the user lastname failed with wrong values')
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context=context)[0]
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname':'firstname'}, context=context)
self.user_model.write(cr, uid, res_id, {'name': 'change firstname'}, context=context)
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context=context)[0]
self.assertEqual(vals['name'], 'change firstname', 'Update of the user lastname failed with wrong name')
self.assertEqual(vals['lastname'], 'change', 'Update of the user lastname failed with wrong lastname')
self.assertEqual(vals['firstname'], 'firstname', 'Update of the user lastname failed with wrong firstname')
def test_update_user_firstname(self): def test_update_user_firstname(self):
cr, uid = self.cr, self.uid
cr, uid, context = self.cr, self.uid, self.context
# create a user # create a user
res_id = self.user_model.create(cr, uid, self.fields_user, context={})
res_id = self.user_model.create(cr, uid, self.fields_user, context=context)
# get the related partner id and add it a firstname # get the related partner id and add it a firstname
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context={})[0]
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname':'firstname'}, context={})
self.user_model.write(cr, uid, res_id, {'name': 'lastname other'}, context={})
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context={})[0]
self.assertEqual(vals['name'] == "lastname other" and
vals['lastname'] == 'lastname other' and
vals['firstname'] == False, True, 'Update of the user firstname failed with wrong values')
flds = self.user_model.read(cr, uid, [res_id], ['partner_id'], context=context)[0]
self.partner_model.write(cr, uid, flds['partner_id'][0], {'firstname':'firstname'}, context=context)
self.user_model.write(cr, uid, res_id, {'name': 'lastname other'}, context=context)
vals = self.user_model.read(cr, uid, [res_id], ['name', 'lastname', 'firstname'], context=context)[0]
self.assertEqual(vals['name'], 'lastname other', 'Update of the user firstname failed with wrong name')
self.assertEqual(vals['lastname'], 'lastname other', 'Update of the user firstname failed with wrong lastname')
self.assertFalse(vals['firstname'], 'Update of the user firstname failed with wrong firstname')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Loading…
Cancel
Save