Changeset View
Changeset View
Standalone View
Standalone View
tests/functional/user_add.py
Show All 26 Lines | def user_add(givenname, sn, preferredlanguage='en_US', **kw): | ||||
domain = conf.get('kolab', 'primary_domain') | domain = conf.get('kolab', 'primary_domain') | ||||
user_type_id = 0 | user_type_id = 0 | ||||
result = wap_client.authenticate(login, password, domain) | result = wap_client.authenticate(login, password, domain) | ||||
user_types = wap_client.user_types_list() | user_types = wap_client.user_types_list() | ||||
for key in user_types['list'].keys(): | for key in user_types['list']: | ||||
if user_types['list'][key]['key'] == 'kolab': | if user_types['list'][key]['key'] == 'kolab': | ||||
user_type_id = key | user_type_id = key | ||||
user_type_info = user_types['list'][user_type_id]['attributes'] | user_type_info = user_types['list'][user_type_id]['attributes'] | ||||
params = { | params = { | ||||
'user_type_id': user_type_id, | 'user_type_id': user_type_id, | ||||
} | } | ||||
for attribute in user_type_info['form_fields'].keys(): | for attribute in user_type_info['form_fields']: | ||||
attr_details = user_type_info['form_fields'][attribute] | attr_details = user_type_info['form_fields'][attribute] | ||||
if isinstance(attr_details, dict): | if isinstance(attr_details, dict): | ||||
if 'optional' not in attr_details or attr_details['optional'] is False or attribute in user_details: | if 'optional' not in attr_details or attr_details['optional'] is False or attribute in user_details: | ||||
params[attribute] = user_details[attribute] | params[attribute] = user_details[attribute] | ||||
elif isinstance(attr_details, list): | elif isinstance(attr_details, list): | ||||
params[attribute] = user_details[attribute] | params[attribute] = user_details[attribute] | ||||
fvg_params = params | fvg_params = params | ||||
fvg_params['object_type'] = 'user' | fvg_params['object_type'] = 'user' | ||||
fvg_params['type_id'] = user_type_id | fvg_params['type_id'] = user_type_id | ||||
fvg_params['attributes'] = [attr for attr in user_type_info['auto_form_fields'].keys() if attr not in params] | fvg_params['attributes'] = [attr for attr in user_type_info['auto_form_fields'] if attr not in params] | ||||
result = wap_client.user_add(params) | result = wap_client.user_add(params) |