diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2011-04-11 11:52:29 +0100 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2011-04-11 11:52:29 +0100 |
commit | a44f887e6609d46f39c6f4266a175dce1671d2a0 (patch) | |
tree | 18da56c093696b9017eec0d62be44ba25339c797 /pykolab/tests/zpush | |
parent | de8818dd793a1b1caff98be0ff03fc3e032f9f92 (diff) | |
download | pykolab-a44f887e6609d46f39c6f4266a175dce1671d2a0.tar.gz |
Pull out auth and conf from becoming multi-instance all over the place. One of each suffices.
Clean up imap module, along with making the imap.cyrus module work better
Diffstat (limited to 'pykolab/tests/zpush')
-rw-r--r-- | pykolab/tests/zpush/__init__.py | 19 | ||||
-rw-r--r-- | pykolab/tests/zpush/test_000_000.py | 86 | ||||
-rw-r--r-- | pykolab/tests/zpush/test_000_001.py | 13 |
3 files changed, 35 insertions, 83 deletions
diff --git a/pykolab/tests/zpush/__init__.py b/pykolab/tests/zpush/__init__.py index 6794725..62783f5 100644 --- a/pykolab/tests/zpush/__init__.py +++ b/pykolab/tests/zpush/__init__.py @@ -21,25 +21,22 @@ import imp import os import sys -import pykolab.logger +import pykolab -from pykolab.conf import Conf from pykolab.constants import * from pykolab.tests.constants import * +from pykolab.translate import _ -class ZpushTest(object): - def __init__(self, conf=None): - if conf: - self.conf = conf - else: - self.conf = Conf() - self.conf.finalize_conf() +log = pykolab.getLogger('pykolab.tests.zpush') +conf = pykolab.getConf() +class ZpushTest(object): + def __init__(self): self.tests = [] # Make sure we parse the [testing] section of the configuration file, if # available. - self.conf.set_options_from_testing_section() + conf.set_options_from_testing_section() # Attempt to create a list of modules for x in range(0,8): @@ -52,7 +49,7 @@ class ZpushTest(object): pass for test in self.tests: - exec("result = %s(self.conf)" %(test)) + exec("result = %s()" %(test)) #name = "from pykolab.tests.zpush.test_%s import Test_%s" %(test_num,test_num) #file, pathname, description = imp.find_module(name, sys.path) diff --git a/pykolab/tests/zpush/test_000_000.py b/pykolab/tests/zpush/test_000_000.py index e0969c2..415de0b 100644 --- a/pykolab/tests/zpush/test_000_000.py +++ b/pykolab/tests/zpush/test_000_000.py @@ -17,92 +17,48 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -import cyruslib +import pykolab -from pykolab.conf import Conf +from pykolab import utils 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': [ - ], - }, - } +log = pykolab.getLogger('pykolab.tests.zpush') +conf = pykolab.getConf() class Test_000_000(object): """ - Preparations for the Test 000 series + Preparations for the Test 000 series. """ def __init__(self, conf=None): self.suite_num = "000" self.suite_test_num = "000" - self.log.info("About to execute preperation task #000 in Test Suite #000"); - self.log.info("We will assume the start situation has been configured"); - self.log.info("such as is described in the documentation"); + log.info("About to execute preperation task #000 in Test Suite #000"); + log.info("We will assume the start situation has been configured"); + log.info("such as is described in the documentation."); - 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) + utils.ask_confirmation("Continue?") # Delete all mailboxes - for user in self.conf.testing_users: + #imap.connect() + #for folder in imap.lm("user/%"): + #imap.dm(folder) + + for user in auth.list_users(domain): 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) + 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: + for user in conf.testing_users: mailbox = "user%s%s" %(imap.SEP,"%(givenname)s@%(domain)s" %(user)) - self.conf.log.debug(_("Creating mailbox: %s") %(mailbox), level=3) + log.debug(_("Creating mailbox: %s") %(mailbox), level=3) imap.cm(mailbox) imap.logout() @@ -113,15 +69,15 @@ class Test_000_000(object): # - 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)) + for user in conf.testing_users: + imap = cyruslib.CYRUS("imap://%s:143" %(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) + log.error(_("Authentication failure for %s") %("%(givenname)s@%(domain)s" %(user)), recoverable=True) continue - if self.conf.debuglevel > 3: + if conf.debuglevel > 3: imap.VERBOSE = True imap.subscribe("INBOX") diff --git a/pykolab/tests/zpush/test_000_001.py b/pykolab/tests/zpush/test_000_001.py index c7bfbb6..204aba3 100644 --- a/pykolab/tests/zpush/test_000_001.py +++ b/pykolab/tests/zpush/test_000_001.py @@ -17,11 +17,16 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -from pykolab.conf import Conf +import pykolab + +from pykolab import utils from pykolab.constants import * from pykolab.tests.constants import * from pykolab.translate import _ +log = pykolab.getLogger('pykolab.tests.zpush') +conf = pykolab.getConf() + class Test_000_001(object): """ First, basic test. @@ -34,12 +39,6 @@ class Test_000_001(object): self.suite_num = "000" self.suite_test_num = "001" - if not conf: - self.conf = Conf() - self.conf.finalize_conf() - else: - self.conf = conf - # Create some test calendar items for item in TEST_ITEMS: try: |