summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pykolab/tests/__init__.py57
-rw-r--r--pykolab/tests/calendar.py231
-rw-r--r--pykolab/tests/constants.py92
-rw-r--r--pykolab/tests/contacts.py147
-rw-r--r--pykolab/tests/create-contacts.py106
-rw-r--r--pykolab/tests/imap/__init__.py0
-rw-r--r--pykolab/tests/imap/test_create_mailbox.py44
-rw-r--r--pykolab/tests/imap/test_login.py61
-rw-r--r--pykolab/tests/imap/test_login_admin.py40
-rw-r--r--pykolab/tests/mail.py125
-rw-r--r--pykolab/tests/tests.py192
-rw-r--r--pykolab/tests/wap/__init__.py0
-rw-r--r--pykolab/tests/wap/test_login.py40
-rw-r--r--pykolab/tests/zpush/__init__.py63
-rw-r--r--pykolab/tests/zpush/test_000_000.py93
-rw-r--r--pykolab/tests/zpush/test_000_001.py55
16 files changed, 400 insertions, 946 deletions
diff --git a/pykolab/tests/__init__.py b/pykolab/tests/__init__.py
index 9b902be..3aefdc3 100644
--- a/pykolab/tests/__init__.py
+++ b/pykolab/tests/__init__.py
@@ -26,7 +26,6 @@ import time
import pykolab
from pykolab.constants import *
-from pykolab.tests.constants import *
from pykolab.translate import _
log = pykolab.getLogger('pykolab.tests')
@@ -34,16 +33,11 @@ conf = pykolab.getConf()
class Tests(object):
def __init__(self):
+ import tests
+ tests.__init__()
test_group = conf.add_cli_parser_option_group(_("Test Options"))
- for item in TEST_ITEMS:
- test_group.add_option( "--%s" %(item['name']),
- dest = "%s" %(item['name']),
- action = "store_true",
- default = False,
- help = _("Submit a number of items to the %s") %(item['mailbox']))
-
test_group.add_option( "--suite",
dest = "test_suites",
action = "append",
@@ -51,33 +45,28 @@ class Tests(object):
help = _("Run tests in suite SUITE. Implies a certain set of items being tested."),
metavar = "SUITE")
- delivery_group = conf.add_cli_parser_option_group(_("Content Delivery Options"))
-
- delivery_group.add_option( "--use-mail",
- dest = "use_mail",
- action = "store_true",
- default = False,
- help = _("Send messages containing the items through mail (requires proper infrastructure)"))
+ conf.finalize_conf()
- delivery_group.add_option( "--use-imap",
- dest = "use_imap",
- action = "store_true",
- default = False,
- help = _("Inject messages containing the items through IMAP"))
+ def run(self):
+ if len(conf.test_suites) > 0:
+ for test_suite in conf.test_suites:
+ print test_suite
+ else:
+ to_execute = []
- delivery_group.add_option( "--use-lmtp",
- dest = "use_lmtp",
- action = "store_true",
- default = False,
- help = _("Deliver messages containing the items through LMTP"))
+ arg_num = 0
+ for arg in sys.argv[1:]:
+ print "arg", arg
+ arg_num += 1
+ if not arg.startswith('-') and len(sys.argv) >= arg_num:
+ if tests.tests.has_key(sys.argv[arg_num].replace('-','_')):
+ print "tests.tests.has_key", sys.argv[arg_num].replace('-','_')
+ to_execute.append(sys.argv[arg_num].replace('-','_'))
- conf.finalize_conf()
+ print "to_execute", to_execute
+ if len(to_execute) > 0:
+ print "'_'.join(to_execute)", '_'.join(to_execute)
+ tests.execute('_'.join(to_execute))
+ else:
+ tests.execute('help')
- def run(self):
- # Execute the suites first.
- for suite in conf.test_suites:
- try:
- exec("from pykolab.tests.%s import %sTest" %(suite,suite.capitalize()))
- exec("%stest = %sTest()" %(suite,suite.capitalize()))
- except ImportError, e:
- conf.log.error(_("Tests for suite %s failed to load. Aborting.") %(suite.capitalize()))
diff --git a/pykolab/tests/calendar.py b/pykolab/tests/calendar.py
deleted file mode 100644
index f5b8f68..0000000
--- a/pykolab/tests/calendar.py
+++ /dev/null
@@ -1,231 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2010-2012 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 3 or, at your option, any later version
-#
-# 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 calendar
-import datetime
-import os
-import random
-import time
-
-from pykolab.conf import Conf
-from pykolab.constants import *
-from pykolab.tests.constants import *
-from pykolab.translate import _
-
-class CalendarItem(object):
- def __init__(self, item_num=0, total_num=1, start=0, end=0, folder=None, user=None):
- """
- A calendar item is created from a template.
-
- The attributes that can be modified are set to defaults first.
- """
-
- if user == None:
- user = TEST_USERS[random.randint(0,(len(TEST_USERS)-1))]
-
- # Used for some randomization
- self.item_num = item_num
- self.total_num = total_num
- self.event_boundary_start = int(start)
- self.event_boundary_end = int(end)
-
- # Initial event data
- self.event_location = "one or the other meeting room"
- self.event_recurrence = ""
- self.event_summary = "Test Event %d" %(item_num)
-
- from_user = TEST_USERS[random.randint(0,(len(TEST_USERS)-1))]
- self.from_name_str = "%s %s" %(from_user['givenname'].capitalize(),from_user['sn'].capitalize())
- self.from_email_str = "%(givenname)s@%(domain)s" %(from_user)
- self.kolab_event_date_creation = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
- self.kolab_event_date_start = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
- self.kolab_event_date_end = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
- self.rfc_2822_sent_date = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
- self.to_name_str = "%s %s" %(user['givenname'].capitalize(),user['sn'].capitalize())
- self.to_email_str = "%(givenname)s@%(domain)s" %(user)
-
- self.uid = "%s.%s" %(str(random.randint(1000000000,9999999999)),str(random.randint(0,999)).zfill(3))
-
- if folder:
- self.mailbox = folder
- else:
- self.mailbox = "INBOX/Calendar"
-
- # Status information
- self.dates_randomized = False
-
- self.randomize_recurrence()
- self.randomize_dates()
-
- def randomize_dates(self):
- """
- Randomize all dates in the event but make sure they
- do make sense.
-
- Ergo, the start date is before the end date, and such.
-
- Also, take into account the total number of calendar items, so that
- we do not clutter.
- """
-
- if self.dates_randomized:
- return
-
- # The ratio is 1/2 goes to the past, 1/8 goes to this month, 3/8 goes to the future months.
- # Over 10.000 items, that is 5000 in the past -> 250 days a year, 4 appointments a day, 5 year
- # 125 this month
- # 4875 to future
-
- # We have two integers (epoch values), a start and an end
- mystart = random.randint(self.event_boundary_start,self.event_boundary_end)
- myend = mystart + (1800 * random.randint(1,4))
-
- self.kolab_event_date_start = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(mystart))
- self.kolab_event_date_end = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(myend))
-
- # Calculate the timespan we're serving assuming 4-6 appointments a day;
- self.dates_randomized = True
-
- def randomize_recurrence(self):
- """
- Randomize the recurrence of this event.
-
- One every so many events has recurrence.
- """
- return
-
- if not random.randint(1,15) == 1:
- return
-
- # The recurrence day (of the week)
- recur_day = random.randint(0,6)
-
-# # Seek a day somewhere in the past with this day_number
-# for days_in_week in calendar.itermonthdates():
-# # day_of_week is a list of weeks, where 0 is outside the month
-# # described in the call to calendar.itermonthdays(), and so
-# # we are able now to find the first day for this recurrence.
-# for day_date in days_in_week:
-# print day_date
-
- self.dates_randomized = True
-
- def __str__(self):
- for tpl_file_location in [ '/usr/share/kolab/tests/kcal-event.tpl', './share/tests/kcal-event.tpl' ]:
- if os.path.isfile(tpl_file_location):
- tpl_file = open(tpl_file_location, 'r')
- tpl_orig = tpl_file.read()
- tpl_file.close()
- break
- return tpl_orig % self.__dict__
-
-def create_items(conf, num=None, folder=None):
- for item in TEST_ITEMS:
- if item['name'] == 'calendar':
- info = item
-
- if num:
- info['number'] = int(num)
-
- conf.log.debug(_("Creating %d Events") %(info['number']), level=3)
-
- alloc_uids = []
-
- if os.path.isfile('./share/tests/kcal-event.tpl'):
- tpl_file = open('./share/tests/kcal-event.tpl', 'r')
- tpl_orig = tpl_file.read()
- tpl_file.close()
-
- (start_boundary,end_boundary) = set_bounds(num=num)
-
- imap = True
-
- for user in conf.testing_users:
- if conf.use_mail:
- pass
- elif conf.use_lmtp:
- pass
- elif conf.use_imap:
- import imaplib
- if imap:
- del imap
- imap = imaplib.IMAP4(conf.testing_server)
- imap.login("%(givenname)s@%(domain)s" %(user), user['password'])
- else:
- pass
-
- #print "Running for user %(givenname)s@%(domain)s" %(user)
- item_num = 0
-
- while item_num < int(info['number']):
- conf.log.debug(_("Creating Calendar item number %d") %(item_num+1), level=5)
-
- item = CalendarItem(item_num=(item_num+1), total_num=num, start=start_boundary, end=end_boundary, folder=folder, user=user)
-
- if not item.uid in alloc_uids:
- alloc_uids.append(item.uid)
- else:
- continue
-
- msg = str(item)
-
- if conf.use_mail:
- conf.log.debug(_("Sending UID message %s through SMTP targeting user %s@%s") %(item.uid,user['givenname'],user['domain']), level=9)
-
- elif conf.use_lmtp:
- conf.log.debug(_("Sending UID message %s through LMTP targeting user %s@%s") %(item.uid,user['givenname'],user['domain']), level=9)
-
- elif conf.use_imap:
- conf.log.debug(_("Saving UID message %s to IMAP (user %s, folder %s)") %(item.uid,user['givenname'],item.mailbox), level=9)
- imap.append(item.mailbox, '', imaplib.Time2Internaldate(time.time()), msg)
- else:
- conf.log.debug(_("Somehow ended up NOT sending these messages"), level=9)
-
- item_num +=1
-
-def set_bounds(num=0):
- """
- Set the lower and upper boundaries for this event, using the
- total number of events and a reasonable but random average number
- of appointments.
-
- returns a tuple epoch (start, end)
- """
-
- # Pretend anywhere between 0 and 5 events per workday,
- # Multiply by the number of workdays a week,
- # Divide that by 7 for a nice, float average.
- events_per_week_avg = float(random.randint(10,25))
- events_per_day_avg = events_per_week_avg / 7
-
- ratio = [ 6, 4 ]
-
- # Given the total number of events to be created, and the average number
- # of events per day, we can now look at what the lower boundary would be,
- # compared to today.
- days_to_go_back = (((num / events_per_day_avg) / 10 ) * ratio[0])
- days_to_go_forward = (((num / events_per_day_avg) / 10 ) * ratio[1])
-
- now = time.time()
- start_of_day = now - (now % (24 * 60 * 60))
-
- boundary_start = start_of_day - (days_to_go_back * 24 * 60 * 60)
- boundary_end = start_of_day + (days_to_go_forward * 24 * 60 * 60)
-
- return (boundary_start,boundary_end)
diff --git a/pykolab/tests/constants.py b/pykolab/tests/constants.py
deleted file mode 100644
index 6a9853f..0000000
--- a/pykolab/tests/constants.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2010-2012 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 3 or, at your option, any later version
-#
-# 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 datetime
-import os
-import random
-import time
-
-TEST_ALPHABET = ""
-for num in range(33,256):
- TEST_ALPHABET = "%s%s" %(TEST_ALPHABET,unichr(num))
-
-TEST_ITEMS = [
- {
- 'name': 'calendar',
- 'mailbox': 'Calendar',
- 'template': 'kcal-event.tpl',
- 'number': 10,
- # 6 years ago
- 'calendar_start': "%d" %(time.time() - (60*60*24*365*6)),
- # 4 years forward
- 'calendar_end': "%d" %(time.time() - (60*60*24*365*6)),
- },
- {
- 'name': 'contacts',
- 'mailbox': 'Contacts',
- 'template': 'kaddress-contact.tpl',
- 'number': 10,
- },
-
- {
- 'name': 'mail',
- 'mailbox': 'INBOX',
- 'template': 'kaddress-contact.tpl',
- 'number': 10,
- },
- ]
-
-TEST_USERS = [
- #{
- #'givenname': 'john',
- #'sn': 'doe',
- #'domain': 'doe.org'
- #},
- {
- 'givenname': 'joe',
- 'sn': 'sixpack',
- 'domain': 'sixpack.com'
- },
- #{
- #'givenname': 'max',
- #'sn': 'sixpack',
- #'domain': 'sixpack.com'
- #},
- #{
- #'givenname': 'min',
- #'sn': 'sixpack',
- #'domain': 'sixpack.com'
- #},
- #{
- #'givenname': 'joe',
- #'sn': 'imum',
- #'domain': 'imum.net'
- #},
- {
- 'givenname': 'max',
- 'sn': 'imum',
- 'domain': 'imum.net'
- },
- #{
- #'givenname': 'min',
- #'sn': 'imum',
- #'domain': 'imum.net'
- #},
- ]
-
diff --git a/pykolab/tests/contacts.py b/pykolab/tests/contacts.py
deleted file mode 100644
index 156253c..0000000
--- a/pykolab/tests/contacts.py
+++ /dev/null
@@ -1,147 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2010-2012 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 3 or, at your option, any later version
-#
-# 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 calendar
-import datetime
-import imaplib
-import os
-import random
-import time
-
-import pykolab
-
-from pykolab.constants import *
-from pykolab.tests.constants import *
-from pykolab.translate import _
-
-log = pykolab.getLogger('pykolab.tests.contacts')
-
-conf = pykolab.getConf()
-
-imap = pykolab.imap
-
-class ContactsItem(object):
- def __init__(self, item_num=0, total_num=1, folder=None, user=None):
- """
- A contact item is created from a template.
-
- The attributes that can be modified are set to defaults first.
- """
-
- if user == None:
- user = TEST_USERS[random.randint(0,(len(TEST_USERS)-1))]
-
- # Used for some randomization
- self.item_num = item_num
- self.total_num = total_num
-
- # Initial event data
- self.kolab_contact_given_name = "John"
- self.kolab_contact_last_name = "von Test"
- self.kolab_contact_email_str = "john@von.test"
- self.kolab_contact_mobile_number = "+31612345678"
-
- from_user = TEST_USERS[random.randint(0,(len(TEST_USERS)-1))]
-
- self.from_name_str = "%s %s" %(from_user['givenname'].capitalize(),from_user['sn'].capitalize())
- self.from_email_str = "%(givenname)s@%(domain)s" %(from_user)
-
- self.kolab_creation_date = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
-
- self.rfc_2822_sent_date = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
-
- self.to_name_str = "%s %s" %(user['givenname'].capitalize(),user['sn'].capitalize())
- self.to_email_str = "%(givenname)s@%(domain)s" %(user)
-
- self.uid = "%s.%s" %(str(random.randint(1000000000,9999999999)),str(random.randint(0,999)).zfill(3))
-
- if folder:
- self.mailbox = folder
- else:
- self.mailbox = "Contacts"
-
- self.randomize_contact()
-
- def randomize_contact(self):
- """
- Randomize the contact's information.
-
- """
- pass
-
- def __str__(self):
- for tpl_file_location in [ '/usr/share/kolab/tests/kaddress-contact.tpl', './share/tests/kaddress-contact.tpl', '../share/tests/kaddress-contact.tpl' ]:
- if os.path.isfile(tpl_file_location):
- tpl_file = open(tpl_file_location, 'r')
- tpl_orig = tpl_file.read()
- tpl_file.close()
- break
- return tpl_orig % self.__dict__
-
-def create_items(conf, num=None, folder=None):
- for item in TEST_ITEMS:
- if item['name'] == 'contacts':
- info = item
-
- if num:
- info['number'] = int(num)
-
- log.debug(_("Creating %d Contacts") %(info['number']), level=3)
-
- alloc_uids = []
-
- for user in eval(conf.get('testing','users')):
- if conf.use_mail:
- pass
- elif conf.use_lmtp:
- pass
- elif conf.use_imap:
- imap.connect(login=False)
- imap.login("%(givenname)s.%(sn)s@%(domain)s" %(user), user['password'])
- else:
- pass
-
- #print "Running for user %(givenname)s@%(domain)s" %(user)
- item_num = 0
-
- while item_num < int(info['number']):
- log.debug(_("Creating Contact item number %d") %(item_num+1), level=5)
-
- item = ContactsItem(item_num=(item_num+1), total_num=num, folder=folder, user=user)
-
- if not item.uid in alloc_uids:
- alloc_uids.append(item.uid)
- else:
- continue
-
- msg = str(item)
-
- if conf.use_mail:
- log.debug(_("Sending UID message %s through SMTP targeting user %s@%s") %(item.uid,user['givenname'],user['domain']), level=9)
-
- elif conf.use_lmtp:
- log.debug(_("Sending UID message %s through LMTP targeting user %s@%s") %(item.uid,user['givenname'],user['domain']), level=9)
-
- elif conf.use_imap:
- log.debug(_("Saving UID message %s to IMAP (user %s, folder %s)") %(item.uid,user['givenname'],item.mailbox), level=9)
- imap.imap.m.append(item.mailbox, '', imaplib.Time2Internaldate(time.time()), msg)
- else:
- log.debug(_("Somehow ended up NOT sending these messages"), level=9)
-
- item_num +=1
diff --git a/pykolab/tests/create-contacts.py b/pykolab/tests/create-contacts.py
deleted file mode 100644
index 8b09a25..0000000
--- a/pykolab/tests/create-contacts.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# -*- coding: utf-8 -*-
-# Copyright 2010-2012 Kolab Systems AG (http://www.kolabsys.com)
-#
-# Paul James Adams <adams a 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 3 or, at your option, any later version
-#
-# 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 os, random, sys
-
-if __name__ == "__main__":
- wanted_num = int(sys.argv[1])
-
- contact_tpl_file = open('./kaddress-contact.tpl', 'r')
- contact_tpl_orig = contact_tpl_file.read()
- contact_tpl_file.close()
-
- users = ['john', 'joe', 'max']
- domains = ['doe.org', 'sixpack.com', 'imum.net']
- uid_alloc = []
-
- alphabet = "abcdefghijklmnopqrstuvwxwz"
-
- user_num = 0
-
- for user in users:
- num = 0
- while num <= wanted_num:
- uid = "%s.%s" %(str(random.randint(1000000000,9999999999)),str(random.randint(0,999)).zfill(3))
- if not uid in uid_alloc:
- uid_alloc.append(uid)
- else:
- continue
-
- domain = domains[random.randint(0,2)]
-
- contact_tpl = contact_tpl_orig
-
- birthday = ""
- if random.randint(0,100) >= 75:
- year = str(random.randint(1960, 2010))
- month = str(random.randint(1,12)).zfill(2)
- day = str(random.randint(1,27)).zfill(2)
- birthday = "%s-%s-%s" % (year, month, day)
-
- middle_names = ""
- if random.randint(0,100) >= 50:
- middle_names = ''.join(random.sample(alphabet, random.randint(4, 8))).capitalize()
-
- number = ""
- if random.randint(0,100) >= 25:
- number = "+441234567890"
-
- given_name = ''.join(random.sample(alphabet, random.randint(4, 8))).capitalize()
- last_name = ''.join(random.sample(alphabet, random.randint(4, 8))).capitalize()
-
- contact = {
- 'uid': uid,
- 'user': user,
- 'user_email': "%s@%s" % (user, domain),
- 'given_name': given_name,
- 'middle_names': middle_names,
- 'last_name': last_name,
- 'full_name': "%s %s %s" % (given_name, middle_names, last_name),
- 'display_name': "%s %s" % (given_name, last_name),
- 'email_address': "%s@%s" % (given_name, domain),
- 'number': number,
- 'birthday': birthday
- }
-
- directory = "/kolab/var/imapd/spool/domain/%s/%s/%s/user/%s/Contacts" %(domains[user_num][0],domains[user_num],user[0],user)
- if not os.path.isdir(directory):
- directory = "./kolab/var/imapd/spool/domain/%s/%s/%s/user/%s/Contacts" %(domains[user_num][0],domains[user_num],user[0],user)
- if not os.path.isdir(directory):
- os.makedirs(directory)
-
- out = open("%s/%d." %(directory,num), 'w')
-
- for key in contact.keys():
- contact_tpl = contact_tpl.replace("@@%s@@" % key, '%s' % contact[key])
-
- out.write(contact_tpl)
- out.close()
-
- try:
- os.chown("%s/%d." %(directory,num), 19415, 19415)
- except:
- pass
- num += 1
-
- user_num += 1
diff --git a/pykolab/tests/imap/__init__.py b/pykolab/tests/imap/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/pykolab/tests/imap/__init__.py
diff --git a/pykolab/tests/imap/test_create_mailbox.py b/pykolab/tests/imap/test_create_mailbox.py
new file mode 100644
index 0000000..e9a4901
--- /dev/null
+++ b/pykolab/tests/imap/test_create_mailbox.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 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 3 or, at your option, any later version
+#
+# 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.tests import tests
+
+import pykolab
+
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.tests')
+conf = pykolab.getConf()
+
+auth = pykolab.auth
+imap = pykolab.imap
+
+def __init__():
+ tests.register('create_mailbox', execute, group='imap', description=description())
+
+def description():
+ return """Create a mailbox."""
+
+def execute(*args, **kw):
+ return
+ mailbox = conf.cli_args.pop(0)
+
+ imap.connect()
+ imap.cm(mailbox)
+
diff --git a/pykolab/tests/imap/test_login.py b/pykolab/tests/imap/test_login.py
new file mode 100644
index 0000000..951abd9
--- /dev/null
+++ b/pykolab/tests/imap/test_login.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 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 3 or, at your option, any later version
+#
+# 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 time
+import traceback
+
+from pykolab.tests import tests
+
+import pykolab
+
+from pykolab.translate import _
+from pykolab import utils
+
+log = pykolab.getLogger('pykolab.tests')
+conf = pykolab.getConf()
+
+auth = pykolab.auth
+imap = pykolab.imap
+
+def __init__():
+ tests.register('login', execute, group='imap', description=description())
+
+def description():
+ return """Connect to IMAP and login."""
+
+def execute(*args, **kw):
+ try:
+ log.debug(_("Connecting at %s") %(time.time()), level=8)
+ imap.connect(login=False)
+ log.debug(_("Connected at %s") %(time.time()), level=8)
+ except:
+ raise TestFailureException, __file__
+
+ try:
+ log.debug(_("Logging in at %s") %(time.time()), level=8)
+ imap.login('doe', password='0cvRKSdluPU4ewN')
+ log.debug(_("Logged in at %s") %(time.time()), level=8)
+ #imap.login('doe', password='bla')
+ except:
+ raise TestFailureException(__file__)
+
+class TestFailureException(BaseException):
+ def __init__(self, test_file):
+ log.error(_("Test failure in %s") %(test_file))
+ utils.ask_confirmation('Would you like to log this as a bug?') \ No newline at end of file
diff --git a/pykolab/tests/imap/test_login_admin.py b/pykolab/tests/imap/test_login_admin.py
new file mode 100644
index 0000000..6344bc7
--- /dev/null
+++ b/pykolab/tests/imap/test_login_admin.py
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 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 3 or, at your option, any later version
+#
+# 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.tests import tests
+
+import pykolab
+
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.tests')
+conf = pykolab.getConf()
+
+auth = pykolab.auth
+imap = pykolab.imap
+
+def __init__():
+ tests.register('login_admin', execute, group='imap', description=description())
+
+def description():
+ return """Connect to IMAP and login as an administrator."""
+
+def execute(*args, **kw):
+ imap.connect()
+
diff --git a/pykolab/tests/mail.py b/pykolab/tests/mail.py
deleted file mode 100644
index 4304149..0000000
--- a/pykolab/tests/mail.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2010-2012 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 3 or, at your option, any later version
-#
-# 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 calendar
-import datetime
-import mailbox
-import os
-import random
-import time
-
-from pykolab.conf import Conf
-from pykolab.constants import *
-from pykolab.tests.constants import *
-from pykolab.translate import _
-
-class MailItem(object):
- def __init__(self, item_num=0, total_num=1, folder=None, user=None):
- """
- A mail item is created from a template.
-
- The attributes that can be modified are set to defaults first.
- """
-
- if user == None:
- user = TEST_USERS[random.randint(0,(len(TEST_USERS)-1))]
-
- # Used for some randomization
- self.item_num = item_num
- self.total_num = total_num
-
- # Initial event data
- self.kolab_contact_given_name = "John"
- self.kolab_contact_last_name = "von Test"
- self.kolab_contact_email_str = "john@von.test"
- self.kolab_contact_mobile_number = "+31612345678"
-
- from_user = TEST_USERS[random.randint(0,(len(TEST_USERS)-1))]
-
- self.from_name_str = "%s %s" %(from_user['givenname'].capitalize(),from_user['sn'].capitalize())
- self.from_email_str = "%(givenname)s@%(domain)s" %(from_user)
-
- self.kolab_creation_date = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
-
- self.rfc_2822_sent_date = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
-
- self.to_name_str = "%s %s" %(user['givenname'].capitalize(),user['sn'].capitalize())
- self.to_email_str = "%(givenname)s@%(domain)s" %(user)
-
- self.uid = "%s.%s" %(str(random.randint(1000000000,9999999999)),str(random.randint(0,999)).zfill(3))
-
- if folder:
- self.mailbox = folder
- else:
- self.mailbox = "INBOX"
-
- self.randomize_mail()
-
- def randomize_mail(self):
- """
- Randomize some of the contents of the mail.
- """
-
- pass
-
- def __str__(self):
- return ""
-
-def create_items(conf, num=None, folder=None):
- for item in TEST_ITEMS:
- if item['name'] == 'mail':
- info = item
-
- if num:
- info['number'] = int(num)
-
- conf.log.debug(_("Creating %d Mails") %(info['number']), level=3)
-
- imap = True
-
- for user in conf.testing_users:
- if conf.use_mail:
- pass
- elif conf.use_lmtp:
- pass
- elif conf.use_imap:
- import imaplib
- if imap:
- del imap
- imap = imaplib.IMAP4(conf.testing_server)
- imap.login("%(givenname)s@%(domain)s" %(user), user['password'])
- else:
- pass
-
- mb = mailbox.mbox('./share/tests/mail/lists.fedoraproject.org/devel/2010-September.txt')
- for key in mb.keys():
-
- msg = mb.get_string(key)
-
- if conf.use_mail:
- conf.log.debug(_("Sending message %s through SMTP targeting user %s@%s") %(key,user['givenname'],user['domain']), level=9)
-
- elif conf.use_lmtp:
- conf.log.debug(_("Sending message %s through LMTP targeting user %s@%s") %(key,user['givenname'],user['domain']), level=9)
-
- elif conf.use_imap:
- conf.log.debug(_("Saving message %s to IMAP (user %s, folder %s)") %(key,user['givenname'],"INBOX"), level=9)
- imap.append("INBOX", '', imaplib.Time2Internaldate(time.time()), msg)
- else:
- conf.log.debug(_("Somehow ended up NOT sending these messages"), level=9)
diff --git a/pykolab/tests/tests.py b/pykolab/tests/tests.py
new file mode 100644
index 0000000..8a3c915
--- /dev/null
+++ b/pykolab/tests/tests.py
@@ -0,0 +1,192 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 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 3 or, at your option, any later version
+#
+# 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 os
+import sys
+
+import pykolab
+
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.tests')
+conf = pykolab.getConf()
+
+tests = {}
+test_groups = {}
+
+def __init__():
+ # We only want the base path
+ tests_base_path = os.path.dirname(__file__)
+
+ for tests_path, dirnames, filenames in os.walk(tests_base_path):
+ if not tests_path == tests_base_path:
+ continue
+
+ for filename in filenames:
+ #print filename
+ if filename.startswith('test_') and filename.endswith('.py'):
+ module_name = filename.replace('.py','')
+ test_name = module_name.replace('test_', '')
+ #print "exec(\"from %s import __init__ as %s_register\"" %(module_name,test_name)
+ exec("from %s import __init__ as %s_register" %(module_name,test_name))
+ exec("%s_register()" %(test_name))
+
+ for dirname in dirnames:
+ register_group(tests_path, dirname)
+
+ register('help', list_tests, description=_("List tests"))
+
+def list_tests(*args, **kw):
+ """
+ List tests
+ """
+
+ __tests = {}
+
+ for test in tests.keys():
+ if isinstance(test, tuple):
+ test_group, test = test
+ __tests[test_group] = {
+ test: tests[(test_group,test)]
+ }
+ else:
+ __tests[test] = tests[test]
+
+ _tests = __tests.keys()
+ _tests.sort()
+
+ for _test in _tests:
+ if not __tests[_test].has_key('group'):
+ if __tests[_test].has_key('function'):
+ # This is a top-level test
+ if not __tests[_test]['description'] == None:
+ print "%-25s - %s" %(_test.replace('_','-'),__tests[_test]['description'])
+ else:
+ print "%-25s" %(_test.replace('_','-'))
+
+ for _test in _tests:
+ if not __tests[_test].has_key('function'):
+ # This is a nested test
+ print "\n" + _("Test Suite: %s") %(_test) + "\n"
+ ___tests = __tests[_test].keys()
+ ___tests.sort()
+ for __test in ___tests:
+ if not __tests[_test][__test]['description'] == None:
+ print "%-4s%-21s - %s" %('',__test.replace('_','-'),__tests[_test][__test]['description'])
+ else:
+ print "%-4s%-21s" %('',__test.replace('_','-'))
+
+def execute(test_name, *args, **kw):
+ print "tests:", tests
+ print "test_name:", test_name
+
+ if not tests.has_key(test_name):
+ log.error(_("No such test."))
+ sys.exit(1)
+
+ if not tests[test_name].has_key('function') and \
+ not tests[test_name].has_key('group'):
+ log.error(_("No such test."))
+ sys.exit(1)
+
+ if tests[test_name].has_key('group'):
+ group = tests[test_name]['group']
+ _test_name = tests[test_name]['test_name']
+ try:
+ exec("from %s.test_%s import cli_options as %s_%s_cli_options" %(group,_test_name,group,test_name))
+ exec("%s_%s_cli_options()" %(group,test_name))
+ except ImportError, e:
+ pass
+
+ else:
+ try:
+ exec("from test_%s import cli_options as %s_cli_options" %(test_name,test_name))
+ exec("%s_cli_options()" %(test_name))
+ except ImportError, e:
+ pass
+
+ conf.finalize_conf()
+
+ tests[test_name]['function'](conf.cli_args, kw)
+
+def register_group(dirname, module):
+ tests_base_path = os.path.join(os.path.dirname(__file__), module)
+
+ tests[module] = {}
+
+ for tests_path, dirnames, filenames in os.walk(tests_base_path):
+ if not tests_path == tests_base_path:
+ continue
+
+ for filename in filenames:
+ if filename.startswith('test_') and filename.endswith('.py'):
+ module_name = filename.replace('.py','')
+ test_name = module_name.replace('test_', '')
+ #print "exec(\"from %s.%s import __init__ as %s_%s_register\"" %(module,module_name,module,test_name)
+ exec("from %s.%s import __init__ as %s_%s_register" %(module,module_name,module,test_name))
+ exec("%s_%s_register()" %(module,test_name))
+
+def register(test_name, func, group=None, description=None, aliases=[]):
+ if not group == None:
+ test = "%s_%s" %(group,test_name)
+ else:
+ test = test_name
+
+ #print "registering", test
+
+ if isinstance(aliases, basestring):
+ aliases = [aliases]
+
+ if tests.has_key(test):
+ log.fatal(_("Test '%s' already registered") %(test))
+ sys.exit(1)
+
+ if tests.has_key(test):
+ log.fatal(_("Test '%s' already registered") %(test))
+ sys.exit(1)
+
+ if callable(func):
+ if group == None:
+ tests[test_name] = {
+ 'function': func,
+ 'description': description
+ }
+ else:
+ tests[group][test_name] = {
+ 'function': func,
+ 'description': description
+ }
+
+ tests[test] = tests[group][test_name]
+ tests[test]['group'] = group
+ tests[test]['test_name'] = test_name
+
+ for alias in aliases:
+ tests[alias] = {
+ 'function': func,
+ 'description': _("Alias for %s") %(test_name)
+ }
+
+##
+## Tests not yet implemented
+##
+
+def not_yet_implemented(*args, **kw):
+ print _("Not yet implemented")
+ sys.exit(1) \ No newline at end of file
diff --git a/pykolab/tests/wap/__init__.py b/pykolab/tests/wap/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/pykolab/tests/wap/__init__.py
diff --git a/pykolab/tests/wap/test_login.py b/pykolab/tests/wap/test_login.py
new file mode 100644
index 0000000..5eed57b
--- /dev/null
+++ b/pykolab/tests/wap/test_login.py
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 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 3 or, at your option, any later version
+#
+# 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.tests import tests
+
+import pykolab
+
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.tests')
+conf = pykolab.getConf()
+
+auth = pykolab.auth
+imap = pykolab.imap
+
+def __init__():
+ tests.register('login', execute, group='wap', description=description())
+
+def description():
+ return """Log in to the Kolab Web Administration Panel API."""
+
+def execute(*args, **kw):
+ return
+
diff --git a/pykolab/tests/zpush/__init__.py b/pykolab/tests/zpush/__init__.py
deleted file mode 100644
index d0af89e..0000000
--- a/pykolab/tests/zpush/__init__.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2010-2012 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 3 or, at your option, any later version
-#
-# 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
-
-from pykolab.constants import *
-from pykolab.tests.constants import *
-from pykolab.translate import _
-
-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.
- 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()" %(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
deleted file mode 100644
index d5197a3..0000000
--- a/pykolab/tests/zpush/test_000_000.py
+++ /dev/null
@@ -1,93 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2010-2012 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 3 or, at your option, any later version
-#
-# 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 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_000(object):
- """
- Preparations for the Test 000 series.
- """
-
- def __init__(self):
- self.suite_num = "000"
- self.suite_test_num = "000"
-
- 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.");
-
- utils.ask_confirmation("Continue?")
-
- # Delete all mailboxes
- #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))):
- #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 conf.testing_users:
- #mailbox = "user%s%s" %(imap.SEP,"%(givenname)s@%(domain)s" %(user))
- #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 conf.testing_users:
- imap = cyruslib.CYRUS("imap://%s:143" %(conf.testing_server))
- try:
- imap.login("%(givenname)s.%(surname)s@%(domain)s" %(user), user['password'])
- except:
- log.error(_("Authentication failure for %s") %("%(givenname)s.%(surname)s@%(domain)s" %(user)))
- continue
-
- if conf.debuglevel > 3:
- imap.VERBOSE = True
-
- imap.subscribe("INBOX")
-
- for mailbox in TEST_FOLDERS.keys():
- imap.cm("%s" %(mailbox))
- for annotation in TEST_FOLDERS[mailbox]['annotations'].keys():
- imap.setannotation("%s" %(mailbox),annotation,TEST_FOLDERS[mailbox]['annotations'][annotation])
-
- imap.subscribe("%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
deleted file mode 100644
index cadd9e5..0000000
--- a/pykolab/tests/zpush/test_000_001.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2010-2012 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 3 or, at your option, any later version
-#
-# 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 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.
-
- Populate the previously created and existing INBOX, Calendar and Contact
- folders with a limited amount of data.
- """
-
- def __init__(self, conf):
- self.suite_num = "000"
- self.suite_test_num = "001"
-
- # 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
-
- self.conf.log.debug("self.conf.%s = %r" %(item['name'], getattr(self.conf, "%s" %(item['name']))), level=9)
-
- if getattr(self.conf, "%s" %(item['name'])):
- exec("create_%s_items(self.conf, num=%d)" %(item['name'],item['number']))
- else:
- self.conf.log.info("not executing %s" %(item['name'].capitalize()))