devtools/testlib.py
branchstable
changeset 7337 67cd9d5b4c2e
parent 7331 7fcc4f22f3e4
child 7338 591d6ed3e1f4
child 7376 38524ca653e5
--- 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: