devtools/_apptest.py
branch3.5
changeset 2920 64322aa83a1d
parent 2733 e73118788a56
child 3877 7ca53fc72a0a
child 4212 ab6573088b4a
equal deleted inserted replaced
2919:662f35236d1c 2920:64322aa83a1d
    24 
    24 
    25 SYSTEM_ENTITIES = ('CWGroup', 'CWUser',
    25 SYSTEM_ENTITIES = ('CWGroup', 'CWUser',
    26                    'CWAttribute', 'CWRelation',
    26                    'CWAttribute', 'CWRelation',
    27                    'CWConstraint', 'CWConstraintType', 'CWProperty',
    27                    'CWConstraint', 'CWConstraintType', 'CWProperty',
    28                    'CWEType', 'CWRType',
    28                    'CWEType', 'CWRType',
    29                    'State', 'Transition', 'TrInfo',
    29                    'Workflow', 'State', 'BaseTransition', 'Transition', 'WorkflowTransition', 'TrInfo', 'SubWorkflowExitPoint',
    30                    'RQLExpression',
    30                    'RQLExpression',
    31                    )
    31                    )
    32 SYSTEM_RELATIONS = (
    32 SYSTEM_RELATIONS = (
    33     # virtual relation
    33     # virtual relation
    34     'identity',
    34     'identity',
    35     # metadata
    35     # metadata
    36     'is', 'is_instance_of', 'owned_by', 'created_by', 'specializes',
    36     'is', 'is_instance_of', 'owned_by', 'created_by', 'specializes',
    37     # workflow related
    37     # workflow related
    38     'state_of', 'transition_of', 'initial_state', 'allowed_transition',
    38     'workflow_of', 'state_of', 'transition_of', 'initial_state', 'allowed_transition',
    39     'destination_state', 'in_state', 'wf_info_for', 'from_state', 'to_state',
    39     'destination_state', 'in_state', 'wf_info_for', 'from_state', 'to_state',
    40     'condition',
    40     'condition', 'subworkflow', 'subworkflow_state', 'subworkflow_exit',
    41     # permission
    41     # permission
    42     'in_group', 'require_group', 'require_permission',
    42     'in_group', 'require_group', 'require_permission',
    43     'read_permission', 'update_permission', 'delete_permission', 'add_permission',
    43     'read_permission', 'update_permission', 'delete_permission', 'add_permission',
    44     # eproperty
    44     # eproperty
    45     'for_user',
    45     'for_user',
   119 
   119 
   120 
   120 
   121     def create_user(self, login, groups=('users',), req=None):
   121     def create_user(self, login, groups=('users',), req=None):
   122         req = req or self.create_request()
   122         req = req or self.create_request()
   123         cursor = self._orig_cnx.cursor(req)
   123         cursor = self._orig_cnx.cursor(req)
   124         rset = cursor.execute('INSERT CWUser X: X login %(login)s, X upassword %(passwd)s,'
   124         rset = cursor.execute('INSERT CWUser X: X login %(login)s, X upassword %(passwd)s',
   125                               'X in_state S WHERE S name "activated"',
       
   126                               {'login': unicode(login), 'passwd': login.encode('utf8')})
   125                               {'login': unicode(login), 'passwd': login.encode('utf8')})
   127         user = rset.get_entity(0, 0)
   126         user = rset.get_entity(0, 0)
   128         cursor.execute('SET X in_group G WHERE X eid %%(x)s, G name IN(%s)'
   127         cursor.execute('SET X in_group G WHERE X eid %%(x)s, G name IN(%s)'
   129                        % ','.join(repr(g) for g in groups),
   128                        % ','.join(repr(g) for g in groups),
   130                        {'x': user.eid}, 'x')
   129                        {'x': user.eid}, 'x')