Commit 6439b065 authored by Nicolas Dumazet's avatar Nicolas Dumazet

- Extend createUser to have it generic enough to cover all user creations

- Split assignment creation apart in createUserAssignment to allow creating
  several assignments
- Return user and assignment objects for easier manipulation
- add a wrapper createSimpleUser to handle 90% of the user creation cases


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29481 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ab293d32
...@@ -212,6 +212,10 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -212,6 +212,10 @@ class ERP5TypeTestCase(PortalTestCase):
This TestCase setups an ERP5Site and installs business templates. This TestCase setups an ERP5Site and installs business templates.
""" """
def shortDescription(self):
doc = self._TestCase__testMethodDoc
return doc and str(self) + ', ' + doc.split("\n")[0].strip() or None
def dummy_test(self): def dummy_test(self):
ZopeTestCase._print('All tests are skipped when --save option is passed ' ZopeTestCase._print('All tests are skipped when --save option is passed '
'with --update_business_templates or without --load') 'with --update_business_templates or without --load')
...@@ -590,22 +594,39 @@ class ERP5TypeTestCase(PortalTestCase): ...@@ -590,22 +594,39 @@ class ERP5TypeTestCase(PortalTestCase):
if verbose: if verbose:
ZopeTestCase._print(' done (%.3fs)\n' % (time.time() - start)) ZopeTestCase._print(' done (%.3fs)\n' % (time.time() - start))
def createUser(self, title, reference, password=None, function=None): def createSimpleUser(self, title, reference, function):
"""
Helper function to create a Simple ERP5 User.
User password is the reference.
"""
user = self.createUser(reference, person_kw=dict(title=title))
assignment = self.createUserAssignement(user, assignment_kw=dict(function=function))
return user
def createUser(self, reference, password=None, person_kw=None):
""" """
Create an ERP5 User, and create her an assignment. Create an ERP5 User.
Default password is the reference. Default password is the reference.
person_kw is passed as additional arguments when creating the person
""" """
if password is None: if password is None:
password = reference password = reference
if person_kw is None:
person_kw = dict()
person = self.portal.person_module.newContent(portal_type='Person', person = self.portal.person_module.newContent(portal_type='Person',
title=title,
reference=reference, reference=reference,
password=password, password=password,
function=function) **person_kw)
# and assign her function return person
assignment = person.newContent(portal_type='Assignment',
function=function) def createUserAssignement(self, user, assignment_kw):
"""
Create an assignment to user.
"""
assignment = user.newContent(portal_type='Assignment', **assignment_kw)
assignment.open() assignment.open()
return assignment
def failIfDifferentSet(self, a, b, msg=""): def failIfDifferentSet(self, a, b, msg=""):
if not msg: if not msg:
......
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