|
@ -1,14 +1,14 @@ |
|
|
# -*- coding: utf-8 -*- |
|
|
# -*- coding: utf-8 -*- |
|
|
# © 2015-TODAY LasLabs Inc. |
|
|
|
|
|
|
|
|
# Copyright 2015-2017 LasLabs Inc. |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
|
|
|
from openerp.tests.common import TransactionCase |
|
|
|
|
|
|
|
|
from odoo.tests.common import TransactionCase |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestResUsers(TransactionCase): |
|
|
class TestResUsers(TransactionCase): |
|
|
|
|
|
|
|
|
def setUp(self, *args, **kwargs): |
|
|
|
|
|
super(TestResUsers, self).setUp(*args, **kwargs) |
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
|
|
super(TestResUsers, self).setUp() |
|
|
self.login = 'LasLabs@ExAmPlE.CoM' |
|
|
self.login = 'LasLabs@ExAmPlE.CoM' |
|
|
self.partner_vals = { |
|
|
self.partner_vals = { |
|
|
'name': 'Partner', |
|
|
'name': 'Partner', |
|
@ -22,19 +22,22 @@ class TestResUsers(TransactionCase): |
|
|
} |
|
|
} |
|
|
self.model_obj = self.env['res.users'] |
|
|
self.model_obj = self.env['res.users'] |
|
|
|
|
|
|
|
|
def _new_record(self, ): |
|
|
|
|
|
|
|
|
def _new_record(self): |
|
|
|
|
|
""" It should enerate a new record to test with """ |
|
|
partner_id = self.env['res.partner'].create(self.partner_vals) |
|
|
partner_id = self.env['res.partner'].create(self.partner_vals) |
|
|
self.vals['partner_id'] = partner_id.id |
|
|
self.vals['partner_id'] = partner_id.id |
|
|
return self.model_obj.create(self.vals) |
|
|
return self.model_obj.create(self.vals) |
|
|
|
|
|
|
|
|
def test_login_is_lowercased_on_create(self, ): |
|
|
|
|
|
|
|
|
def test_login_is_lowercased_on_create(self): |
|
|
|
|
|
""" It should verify the login is set to lowercase on create """ |
|
|
rec_id = self._new_record() |
|
|
rec_id = self._new_record() |
|
|
self.assertEqual( |
|
|
self.assertEqual( |
|
|
self.login.lower(), rec_id.login, |
|
|
self.login.lower(), rec_id.login, |
|
|
'Login was not lowercased when saved to db.', |
|
|
'Login was not lowercased when saved to db.', |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
def test_login_is_lowercased_on_write(self, ): |
|
|
|
|
|
|
|
|
def test_login_is_lowercased_on_write(self): |
|
|
|
|
|
""" It should verify the login is set to lowercase on write """ |
|
|
rec_id = self._new_record() |
|
|
rec_id = self._new_record() |
|
|
rec_id.write({'login': self.login}) |
|
|
rec_id.write({'login': self.login}) |
|
|
self.assertEqual( |
|
|
self.assertEqual( |
|
@ -42,7 +45,8 @@ class TestResUsers(TransactionCase): |
|
|
'Login was not lowercased when saved to db.', |
|
|
'Login was not lowercased when saved to db.', |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
def test_login_search_is_lowercased(self, ): |
|
|
|
|
|
|
|
|
def test_login_search_is_lowercased(self): |
|
|
|
|
|
""" It should verify the login is set to lowercase on search """ |
|
|
rec_id = self._new_record() |
|
|
rec_id = self._new_record() |
|
|
res_id = self.model_obj.search([('login', '=', self.login.upper())]) |
|
|
res_id = self.model_obj.search([('login', '=', self.login.upper())]) |
|
|
res = res_id.id if res_id else False |
|
|
res = res_id.id if res_id else False |