summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2010-10-27 22:52:36 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2010-10-27 22:52:36 +0100
commit9dd56890008a4255dcf4a528b83dcc889013025e (patch)
treebb6a69cf722041139bc6e9eefb6140527bbe4839
parentbfefee96a24c5a5896be635d31708fa7d1431eec (diff)
downloadpykolab-9dd56890008a4255dcf4a528b83dcc889013025e.tar.gz
Add the test suite for zpush
-rw-r--r--pykolab/tests/zpush/__init__.py66
-rw-r--r--pykolab/tests/zpush/test_000_000.py133
-rw-r--r--pykolab/tests/zpush/test_000_001.py47
3 files changed, 246 insertions, 0 deletions
diff --git a/pykolab/tests/zpush/__init__.py b/pykolab/tests/zpush/__init__.py
new file mode 100644
index 0000000..0bbb0ff
--- /dev/null
+++ b/pykolab/tests/zpush/__init__.py
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+import imp
+import os
+import sys
+
+import pykolab.logger
+
+from pykolab.conf import Conf
+from pykolab.constants import *
+from pykolab.tests.constants import *
+
+class ZpushTest(object):
+ def __init__(self, conf=None):
+ if conf:
+ self.conf = conf
+ else:
+ self.conf = Conf()
+ self.conf.finalize_conf()
+
+ self.tests = []
+
+ # Make sure we parse the [testing] section of the configuration file, if
+ # available.
+ self.conf.set_options_from_testing_section()
+
+ # Attempt to create a list of modules
+ for x in range(0,8):
+ for y in range(0,8):
+ test_num = "%s_%s" %(str(x).zfill(3),str(y).zfill(3))
+ try:
+ exec("from test_%s import Test_%s" %(test_num,test_num))
+ self.tests.append("Test_%s" %(test_num))
+ except ImportError, e:
+ pass
+
+ for test in self.tests:
+ exec("result = %s(self.conf)" %(test))
+
+ #name = "from pykolab.tests.zpush.test_%s import Test_%s" %(test_num,test_num)
+ #file, pathname, description = imp.find_module(name, sys.path)
+
+ #try:
+ #plugin = imp.load_module(mod_name, file, pathname, description)
+ #finally:
+ #file.close()
+ #plugins[name] = plugin
+
+#print plugins
diff --git a/pykolab/tests/zpush/test_000_000.py b/pykolab/tests/zpush/test_000_000.py
new file mode 100644
index 0000000..ed40ca9
--- /dev/null
+++ b/pykolab/tests/zpush/test_000_000.py
@@ -0,0 +1,133 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+import cyruslib
+
+from pykolab.conf import Conf
+from pykolab.constants import *
+from pykolab.tests.constants import *
+from pykolab.translate import _
+
+TEST_FOLDERS = {
+ 'Calendar': {
+ 'annotations': {
+ "/vendor/kolab/folder-test": "true",
+ "/vendor/kolab/folder-type": "event.default"
+ },
+ 'acls': [
+ ],
+ },
+
+ 'Contacts': {
+ 'annotations': {
+ "/vendor/kolab/folder-type": "contact.default"
+ },
+ 'acls': [
+ ],
+ },
+
+ 'Journal': {
+ 'annotations': {
+ "/vendor/kolab/folder-test": "true",
+ "/vendor/kolab/folder-type": "journal.default"
+ },
+ 'acls': [
+ ],
+ },
+ 'Notes': {
+ 'annotations': {
+ "/vendor/kolab/folder-type": "note.default"
+ },
+ 'acls': [
+ ],
+ },
+ 'Tasks': {
+ 'annotations': {
+ "/vendor/kolab/folder-type": "task.default"
+ },
+ 'acls': [
+ ],
+ },
+ }
+
+class Test_000_000(object):
+ """
+ Preparations for the Test 000 series
+ """
+
+ def __init__(self, conf=None):
+ self.suite_num = "000"
+ self.suite_test_num = "000"
+
+ if not conf:
+ self.conf = Conf()
+ self.conf.finalize_conf()
+ else:
+ self.conf = conf
+
+ # Remove all mailboxes
+ # FIXME: Should come from configuration file and/or prompts
+ imap = cyruslib.CYRUS("imap://%s:143" %(self.conf.testing_server))
+ imap.login(self.conf.testing_admin_login,self.conf.testing_admin_password)
+
+ # Delete all mailboxes
+ for user in self.conf.testing_users:
+ for mailbox in imap.lm("user%s%s" %(imap.SEP,"%(givenname)s@%(domain)s" %(user))):
+ self.conf.log.debug(_("Deleting mailbox: %s") %(mailbox), level=3)
+ try:
+ imap.dm(mailbox)
+ except cyruslib.CYRUSError, e:
+ pass
+
+ # Recreate the user top-level mailboxes
+ for user in self.conf.testing_users:
+ mailbox = "user%s%s" %(imap.SEP,"%(givenname)s@%(domain)s" %(user))
+ self.conf.log.debug(_("Creating mailbox: %s") %(mailbox), level=3)
+ imap.cm(mailbox)
+
+ imap.logout()
+
+ del imap
+
+ # Have the user themselves:
+ # - create the standard folders
+ # - set the standard annotations
+ # - subscribe
+ for user in self.conf.testing_users:
+ imap = cyruslib.CYRUS("imap://%s:143" %(self.conf.testing_server))
+ try:
+ imap.login("%(givenname)s@%(domain)s" %(user), user['password'])
+ except:
+ self.conf.log.error(_("Authentication failure for %s") %("%(givenname)s@%(domain)s" %(user)), recoverable=True)
+ continue
+
+ if self.conf.debuglevel > 3:
+ imap.VERBOSE = True
+
+ imap.subscribe("INBOX")
+
+ for mailbox in TEST_FOLDERS.keys():
+ imap.cm("INBOX/%s" %(mailbox))
+ for annotation in TEST_FOLDERS[mailbox]['annotations'].keys():
+ imap.setannotation("INBOX/%s" %(mailbox),annotation,TEST_FOLDERS[mailbox]['annotations'][annotation])
+
+ imap.subscribe("INBOX/%s" %(mailbox))
+
+ imap.logout()
+ del imap \ No newline at end of file
diff --git a/pykolab/tests/zpush/test_000_001.py b/pykolab/tests/zpush/test_000_001.py
new file mode 100644
index 0000000..79b3a8a
--- /dev/null
+++ b/pykolab/tests/zpush/test_000_001.py
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+from pykolab.conf import Conf
+from pykolab.constants import *
+from pykolab.tests.constants import *
+from pykolab.translate import _
+
+class Test_000_001(object):
+ def __init__(self, conf):
+ self.suite_num = "000"
+ self.suite_test_num = "001"
+
+ if not conf:
+ self.conf = Conf()
+ else:
+ self.conf = conf
+
+ # Create some test calendar items
+ for item in TEST_ITEMS:
+ try:
+ exec("from pykolab.tests.%s import %sItem, create_items as create_%s_items" %(item['name'],item['name'].capitalize(),item['name']))
+ except ImportError, e:
+ self.conf.log.warning(_("Could not load %sItem from %s, skipping the testing.") %(item['name'].capitalize(),item['name']))
+ continue
+
+ if getattr(self.conf, "%s" %(item['name'])):
+ self.conf.log.info("Would have populated %s a little" %(item['name'].capitalize()))
+ exec("create_%s_items(self.conf, num=%d)" %(item['name'],item['number']))
+ else:
+ self.conf.log.info("not executing %s" %(item['name'].capitalize()))