Commit 64ee5957 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Vincent Pelletier

ERP5TypeTestCase: New method to log in, by user name instead of by id.

Because unit tests were used to choosing a login and setting a password,
making them use such method seems easier than adapting them to use the
existing "login" method, which really works by user id and not by login.
parent 79a2d7e2
......@@ -244,6 +244,10 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
def login(self, user_name='ERP5TypeTestCase', quiet=0):
"""
Most of the time, we need to login before doing anything
ATTENTION: user_name argument in this method is user's ID in
reality. If you want to login by user_name, use loginByUserName()
instead.
"""
try:
PortalTestCase.login(self, user_name)
......@@ -251,6 +255,22 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
self.addERP5TypeTestCaseUser()
return PortalTestCase.login(self, user_name)
def loginByUserName(self, user_name='ERP5TypeTestCase', quiet=0):
"""
Most of the time, we need to login before doing anything
"""
uf = self.portal.acl_users
for i in range(2):
try:
user = uf.getUser(user_name)
if not hasattr(user, 'aq_base'):
user = user.__of__(uf)
newSecurityManager(None, user)
return
except AttributeError:
uf._doAddUser('ERP5TypeTestCase', '', ['Manager', 'Member', 'Assignee',
'Assignor', 'Author', 'Auditor', 'Associate'], [])
def changeSkin(self, skin_name):
"""
Change current Skin
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment