devtools/testlib.py
changeset 2968 0e3460341023
parent 2813 0cf6c8005bf6
child 3163 edfe43ceaa35
equal deleted inserted replaced
2902:dd9f2dd02f85 2968:0e3460341023
   280                     commit=True):
   280                     commit=True):
   281         """create and return a new user entity"""
   281         """create and return a new user entity"""
   282         if password is None:
   282         if password is None:
   283             password = login.encode('utf8')
   283             password = login.encode('utf8')
   284         cursor = self._orig_cnx.cursor(req or self.request())
   284         cursor = self._orig_cnx.cursor(req or self.request())
   285         rset = cursor.execute('INSERT CWUser X: X login %(login)s, X upassword %(passwd)s,'
   285         rset = cursor.execute('INSERT CWUser X: X login %(login)s, X upassword %(passwd)s',
   286                               'X in_state S WHERE S name "activated"',
       
   287                               {'login': unicode(login), 'passwd': password})
   286                               {'login': unicode(login), 'passwd': password})
   288         user = rset.get_entity(0, 0)
   287         user = rset.get_entity(0, 0)
   289         cursor.execute('SET X in_group G WHERE X eid %%(x)s, G name IN(%s)'
   288         cursor.execute('SET X in_group G WHERE X eid %%(x)s, G name IN(%s)'
   290                        % ','.join(repr(g) for g in groups),
   289                        % ','.join(repr(g) for g in groups),
   291                        {'x': user.eid}, 'x')
   290                        {'x': user.eid}, 'x')