[testlib] create_user may now create user's email address stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 09 May 2011 12:03:03 +0200
branchstable
changeset 7337 67cd9d5b4c2e
parent 7335 9a42f480b856
child 7338 591d6ed3e1f4
child 7339 dd5e49a5dcab
[testlib] create_user may now create user's email address
devtools/testlib.py
--- a/devtools/testlib.py	Mon May 09 09:14:09 2011 +0200
+++ b/devtools/testlib.py	Mon May 09 12:03:03 2011 +0200
@@ -356,7 +356,7 @@
 
     @iclassmethod # XXX turn into a class method
     def create_user(self, req, login=None, groups=('users',), password=None,
-                    commit=True, **kwargs):
+                    email=None, commit=True, **kwargs):
         """create and return a new user entity"""
         if isinstance(req, basestring):
             warn('[3.12] create_user arguments are now (req, login[, groups, password, commit, **kwargs])',
@@ -376,6 +376,9 @@
         req.execute('SET X in_group G WHERE X eid %%(x)s, G name IN(%s)'
                     % ','.join(repr(str(g)) for g in groups),
                     {'x': user.eid})
+        if email is not None:
+            req.create_entity('EmailAddress', address=unicode(email),
+                              reverse_primary_email=user)
         user.cw_clear_relation_cache('in_group', 'subject')
         if commit:
             try: