summaryrefslogtreecommitdiffstats
path: root/tests
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
parent30ea265c66630f7961aa957ea8448086977f7a4f (diff)
downloadpykolab-a91c6f384436c910e7f98dfbec5765026fe4e0c5.tar.gz
Add some functional tests, move unit tests to separate directory
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py4
-rw-r--r--tests/functional/__init__.py5
-rw-r--r--tests/functional/test_auth/__init__.py0
-rw-r--r--tests/functional/test_auth/test_001_ldap.py0
-rw-r--r--tests/functional/test_auth/test_002_sql.py0
-rw-r--r--tests/functional/test_auth/test_003_pam.py0
-rw-r--r--tests/functional/test_auth/test_004_saslauthd.py0
-rw-r--r--tests/functional/test_kolabd/__init__.py6
-rw-r--r--tests/functional/test_kolabd/test_001_user_sync.py97
-rw-r--r--tests/functional/test_postfix/__init__.py6
-rw-r--r--tests/functional/test_wap_client/test_002_user_add.py57
-rw-r--r--tests/functional/user_add.py68
-rw-r--r--tests/unit/__init__.py4
-rw-r--r--tests/unit/test-000-imports.py (renamed from tests/test-000-imports.py)0
-rw-r--r--tests/unit/test-001-contact_reference.py (renamed from tests/test-001-contact_reference.py)0
-rw-r--r--tests/unit/test-002-attendee.py (renamed from tests/test-002-attendee.py)0
-rw-r--r--tests/unit/test-003-event.py (renamed from tests/test-003-event.py)0
-rw-r--r--tests/unit/test-004-icalendar.py (renamed from tests/test-004-icalendar.py)0
-rw-r--r--tests/unit/test-005-timezone.py (renamed from tests/test-005-timezone.py)0
19 files changed, 190 insertions, 57 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index b5e7094..e69de29 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,4 +0,0 @@
-import sys
-
-sys.path = [ '.', '..' ] + sys.path
-
diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py
index b9b864f..1020893 100644
--- a/tests/functional/__init__.py
+++ b/tests/functional/__init__.py
@@ -1 +1,4 @@
-from user_add import user_add
+import sys
+
+def setup_module():
+ sys.path = ['.'] + sys.path
diff --git a/tests/functional/test_auth/__init__.py b/tests/functional/test_auth/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/functional/test_auth/__init__.py
diff --git a/tests/functional/test_auth/test_001_ldap.py b/tests/functional/test_auth/test_001_ldap.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/functional/test_auth/test_001_ldap.py
diff --git a/tests/functional/test_auth/test_002_sql.py b/tests/functional/test_auth/test_002_sql.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/functional/test_auth/test_002_sql.py
diff --git a/tests/functional/test_auth/test_003_pam.py b/tests/functional/test_auth/test_003_pam.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/functional/test_auth/test_003_pam.py
diff --git a/tests/functional/test_auth/test_004_saslauthd.py b/tests/functional/test_auth/test_004_saslauthd.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/functional/test_auth/test_004_saslauthd.py
diff --git a/tests/functional/test_kolabd/__init__.py b/tests/functional/test_kolabd/__init__.py
new file mode 100644
index 0000000..d7bf27f
--- /dev/null
+++ b/tests/functional/test_kolabd/__init__.py
@@ -0,0 +1,6 @@
+import pykolab
+
+def setup_package():
+ conf = pykolab.getConf()
+ conf.finalize_conf(fatal=False)
+
diff --git a/tests/functional/test_kolabd/test_001_user_sync.py b/tests/functional/test_kolabd/test_001_user_sync.py
new file mode 100644
index 0000000..2c3a144
--- /dev/null
+++ b/tests/functional/test_kolabd/test_001_user_sync.py
@@ -0,0 +1,97 @@
+import time
+import unittest
+
+import pykolab
+from pykolab import wap_client
+from pykolab.auth import Auth
+from pykolab.imap import IMAP
+
+conf = pykolab.getConf()
+
+class TestKolabDaemon(unittest.TestCase):
+ @classmethod
+ def setup_class(self, *args, **kw):
+ self.user = {
+ 'local': 'john.doe',
+ 'domain': 'example.org'
+ }
+
+ from tests.functional.user_add import user_add
+ user_add("John", "Doe")
+
+ def test_001_user_recipient_policy(self):
+ auth = Auth()
+ auth.connect()
+ recipient = auth.find_recipient("%(local)s@%(domain)s" % (self.user))
+ if hasattr(self, 'assertIsInstance'):
+ self.assertIsInstance(recipient, str)
+
+ self.assertEqual(recipient, "uid=doe,ou=People,dc=example,dc=org")
+
+ result = wap_client.user_info(recipient)
+ self.assertEqual(result['mail'], 'john.doe@example.org')
+ self.assertEqual(result['alias'], ['doe@example.org', 'j.doe@example.org'])
+
+ def test_002_user_mailbox_created(self):
+ time.sleep(2)
+ imap = IMAP()
+ imap.connect()
+
+ folders = imap.lm('user/%(local)s@%(domain)s' % (self.user))
+ self.assertEqual(len(folders), 1)
+
+ def test_003_user_additional_folders_created(self):
+ time.sleep(2)
+ imap = IMAP()
+ imap.connect()
+
+ exec("ac_folders = %s" % (conf.get_raw(conf.get('kolab', 'primary_domain'), 'autocreate_folders')))
+
+ folders = imap.lm('user/%(local)s/*@%(domain)s' % (self.user))
+
+ self.assertEqual(len(folders), len(ac_folders.keys()))
+
+ def test_004_user_folder_annotations_set(self):
+ imap = IMAP()
+ imap.connect()
+
+ exec("ac_folders = %s" % (conf.get_raw(conf.get('kolab', 'primary_domain'), 'autocreate_folders')))
+
+ folders = []
+ folders.extend(imap.lm('user/%(local)s@%(domain)s' % (self.user)))
+ folders.extend(imap.lm('user/%(local)s/*@%(domain)s' % (self.user)))
+
+ for folder in folders:
+ annotation = imap.getannotation(folder)
+ print annotation
+
+ folder_name = '/'.join(folder.split('/')[2:]).split('@')[0]
+ if ac_folders.has_key(folder_name):
+ if ac_folders[folder_name].has_key('annotations'):
+ for _annotation in ac_folders[folder_name]['annotations'].keys():
+ _annotation_value = ac_folders[folder_name]['annotations'][_annotation]
+ self.assertTrue(annotation[annotation.keys().pop()].has_key(_annotation))
+ self.assertEqual(_annotation_value, annotation[annotation.keys().pop()][_annotation])
+
+ def test_005_user_subscriptions(self):
+ imap = IMAP()
+ imap.connect(login=False)
+ login = conf.get('cyrus-imap', 'admin_login')
+ password = conf.get('cyrus-imap', 'admin_password')
+ imap.login_plain(login, password, 'john.doe@example.org')
+
+ folders = imap.lm()
+ self.assertTrue("INBOX" in folders)
+
+ #folders = imap.imap.lsub()
+ #self.assertTrue("Calendar" in folders)
+
+ def test_011_resource_add(self):
+ pass
+
+ def test_012_resource_mailbox_created(self):
+ pass
+
+ def test_013_resource_mailbox_annotation(self):
+ pass
+
diff --git a/tests/functional/test_postfix/__init__.py b/tests/functional/test_postfix/__init__.py
new file mode 100644
index 0000000..d7bf27f
--- /dev/null
+++ b/tests/functional/test_postfix/__init__.py
@@ -0,0 +1,6 @@
+import pykolab
+
+def setup_package():
+ conf = pykolab.getConf()
+ conf.finalize_conf(fatal=False)
+
diff --git a/tests/functional/test_wap_client/test_002_user_add.py b/tests/functional/test_wap_client/test_002_user_add.py
index 55d030d..84eeeb2 100644
--- a/tests/functional/test_wap_client/test_002_user_add.py
+++ b/tests/functional/test_wap_client/test_002_user_add.py
@@ -16,62 +16,15 @@ class TestUserAdd(unittest.TestCase):
self.password = conf.get('ldap', 'bind_pw')
self.domain = conf.get('kolab', 'primary_domain')
- self.user_details = {
- 'givenname': "John",
- 'sn': "Doe",
- 'preferredlanguage': 'en_US',
- 'ou': 'ou=People,dc=example,dc=org',
- 'userpassword': 'Welcome2KolabSystems'
- }
-
self.user = {
'local': 'john.doe',
'domain': 'example.org'
}
- def test_001_user_add(self):
- user_type_id = 0
-
- result = wap_client.authenticate(self.login, self.password, self.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
-
- self.assertTrue(user_type_id > 0, "No 'kolab' user type found")
-
- 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:
- self.assertTrue(self.user_details.has_key(attribute), "No attribute %r in user details" % (attribute))
- params[attribute] = self.user_details[attribute]
- elif isinstance(attr_details, list):
- self.assertTrue(self.user_details.has_key(attribute), "No attribute %r in user details" % (attribute))
- params[attribute] = self.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)
+ from tests.functional.user_add import user_add
+ user_add("John", "Doe")
- def test_003_inbox_created(self):
+ def test_001_inbox_created(self):
time.sleep(2)
imap = IMAP()
imap.connect()
@@ -79,7 +32,7 @@ class TestUserAdd(unittest.TestCase):
folders = imap.lm('user/%(local)s@%(domain)s' % (self.user))
self.assertEqual(len(folders), 1)
- def test_004_autocreate_folders_created(self):
+ def test_002_autocreate_folders_created(self):
time.sleep(2)
imap = IMAP()
imap.connect()
@@ -93,7 +46,7 @@ class TestUserAdd(unittest.TestCase):
self.assertEqual(len(folders), len(ac_folders.keys()))
- def test_005_folder_types_set(self):
+ def test_003_folder_types_set(self):
imap = IMAP()
imap.connect()
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)
+
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
new file mode 100644
index 0000000..b5e7094
--- /dev/null
+++ b/tests/unit/__init__.py
@@ -0,0 +1,4 @@
+import sys
+
+sys.path = [ '.', '..' ] + sys.path
+
diff --git a/tests/test-000-imports.py b/tests/unit/test-000-imports.py
index 17e1c57..17e1c57 100644
--- a/tests/test-000-imports.py
+++ b/tests/unit/test-000-imports.py
diff --git a/tests/test-001-contact_reference.py b/tests/unit/test-001-contact_reference.py
index 7c8f128..7c8f128 100644
--- a/tests/test-001-contact_reference.py
+++ b/tests/unit/test-001-contact_reference.py
diff --git a/tests/test-002-attendee.py b/tests/unit/test-002-attendee.py
index 4298761..4298761 100644
--- a/tests/test-002-attendee.py
+++ b/tests/unit/test-002-attendee.py
diff --git a/tests/test-003-event.py b/tests/unit/test-003-event.py
index 8f76397..8f76397 100644
--- a/tests/test-003-event.py
+++ b/tests/unit/test-003-event.py
diff --git a/tests/test-004-icalendar.py b/tests/unit/test-004-icalendar.py
index 6033a33..6033a33 100644
--- a/tests/test-004-icalendar.py
+++ b/tests/unit/test-004-icalendar.py
diff --git a/tests/test-005-timezone.py b/tests/unit/test-005-timezone.py
index 9b12c66..9b12c66 100644
--- a/tests/test-005-timezone.py
+++ b/tests/unit/test-005-timezone.py