diff options
Diffstat (limited to 'pykolab/tests')
-rw-r--r-- | pykolab/tests/__init__.py | 23 | ||||
-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 |
4 files changed, 48 insertions, 93 deletions
diff --git a/pykolab/tests/__init__.py b/pykolab/tests/__init__.py index 554b214..fba8133 100644 --- a/pykolab/tests/__init__.py +++ b/pykolab/tests/__init__.py @@ -23,16 +23,19 @@ import os import random import time -from pykolab.conf import Conf +import pykolab + from pykolab.constants import * from pykolab.tests.constants import * from pykolab.translate import _ +log = pykolab.getLogger('pykolab.tests') +conf = pykolab.getConf() + class Tests(object): def __init__(self): - self.conf = Conf() - test_group = self.conf.parser.add_option_group(_("Test Options")) + test_group = conf.add_cli_parser_option_group(_("Test Options")) for item in TEST_ITEMS: test_group.add_option( "--%s" %(item['name']), @@ -48,7 +51,7 @@ class Tests(object): help = _("Run tests in suite SUITE. Implies a certain set of items being tested."), metavar = "SUITE") - delivery_group = self.conf.parser.add_option_group(_("Content Delivery Options")) + delivery_group = conf.add_cli_parser_option_group(_("Content Delivery Options")) delivery_group.add_option( "--use-mail", dest = "use_mail", @@ -60,21 +63,21 @@ class Tests(object): dest = "use_imap", action = "store_true", default = False, - help = _("Inject messages containing the items through IMAP (requires imaplib)")) + help = _("Inject messages containing the items through IMAP")) delivery_group.add_option( "--use-lmtp", dest = "use_lmtp", action = "store_true", default = False, - help = _("Deliver messages containing the items through LMTP (requires imaplib)")) + help = _("Deliver messages containing the items through LMTP")) - self.conf.finalize_conf() + conf.finalize_conf() def run(self): # Execute the suites first. - for suite in self.conf.test_suites: + for suite in conf.test_suites: try: exec("from pykolab.tests.%s import %sTest" %(suite,suite.capitalize())) - exec("%stest = %sTest(self.conf)" %(suite,suite.capitalize())) + exec("%stest = %sTest()" %(suite,suite.capitalize())) except ImportError, e: - self.conf.log.error(_("Tests for suite %s failed to load. Aborting.") %(suite.capitalize()), recoverable=False) + conf.log.error(_("Tests for suite %s failed to load. Aborting.") %(suite.capitalize()), recoverable=False) 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: |