summaryrefslogtreecommitdiffstats
path: root/tests/functional/user_add.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-07-20 09:20:19 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-07-20 09:20:19 +0200
commita91c6f384436c910e7f98dfbec5765026fe4e0c5 (patch)
tree99dad86dbc2acd480c6c8f621cd8904863eb1a48 /tests/functional/user_add.py
parent30ea265c66630f7961aa957ea8448086977f7a4f (diff)
downloadpykolab-a91c6f384436c910e7f98dfbec5765026fe4e0c5.tar.gz
Add some functional tests, move unit tests to separate directory
Diffstat (limited to 'tests/functional/user_add.py')
-rw-r--r--tests/functional/user_add.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/functional/user_add.py b/tests/functional/user_add.py
new file mode 100644
index 0000000..0271d43
--- /dev/null
+++ b/tests/functional/user_add.py
@@ -0,0 +1,68 @@
+import pykolab
+
+from pykolab import wap_client
+
+conf = pykolab.getConf()
+
+def user_add(givenname, sn, preferredlanguage='en_US'):
+ if givenname == None:
+ raise Exception
+
+ if givenname == '':
+ raise Exception
+
+ if sn == None:
+ raise Exception
+
+ if sn == '':
+ raise Exception
+
+ user_details = {
+ 'givenname': givenname,
+ 'sn': sn,
+ 'preferredlanguage': preferredlanguage,
+ 'ou': 'ou=People,dc=example,dc=org',
+ 'userpassword': 'Welcome2KolabSystems'
+ }
+
+ login = conf.get('ldap', 'bind_dn')
+ password = conf.get('ldap', 'bind_pw')
+ domain = conf.get('kolab', 'primary_domain')
+
+ user_type_id = 0
+
+ result = wap_client.authenticate(login, password, domain)
+
+ user_types = wap_client.user_types_list()
+
+ for key in user_types['list'].keys():
+ if user_types['list'][key]['key'] == 'kolab':
+ user_type_id = key
+
+ user_type_info = user_types['list'][user_type_id]['attributes']
+
+ params = {
+ 'user_type_id': user_type_id,
+ }
+
+ for attribute in user_type_info['form_fields'].keys():
+ attr_details = user_type_info['form_fields'][attribute]
+
+ if isinstance(attr_details, dict):
+ if not attr_details.has_key('optional') or attr_details['optional'] == False:
+ params[attribute] = user_details[attribute]
+ elif isinstance(attr_details, list):
+ params[attribute] = user_details[attribute]
+
+ fvg_params = params
+ fvg_params['object_type'] = 'user'
+ fvg_params['type_id'] = user_type_id
+ fvg_params['attributes'] = [attr for attr in user_type_info['auto_form_fields'].keys() if not attr in params.keys()]
+
+ exec("retval = wap_client.form_value_generate(%r)" % (params))
+
+ for attribute in user_type_info['auto_form_fields'].keys():
+ params[attribute] = retval[attribute]
+
+ result = wap_client.user_add(params)
+