summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconf.py2
-rwxr-xr-xkolab-cli.py1
-rwxr-xr-xkolabd.py1
-rw-r--r--kolabd/__init__.py18
-rw-r--r--kolabd/process.py3
-rwxr-xr-xsaslauthd.py1
-rw-r--r--saslauthd/__init__.py16
-rwxr-xr-xtest-wallace.py3
-rw-r--r--tests/functional/purge_imap.py1
-rw-r--r--tests/functional/purge_users.py1
-rw-r--r--tests/functional/resource_func.py24
-rw-r--r--tests/functional/synchronize.py1
-rw-r--r--tests/functional/test_kolabd/__init__.py1
-rw-r--r--tests/functional/test_kolabd/test_001_user_sync.py10
-rw-r--r--tests/functional/test_kolabd/test_002_user_rename.py4
-rw-r--r--tests/functional/test_kolabd/test_003_two_johns.py2
-rw-r--r--tests/functional/test_postfix/__init__.py1
-rw-r--r--tests/functional/test_wallace/__init__.py1
-rw-r--r--tests/functional/test_wallace/test_001_user_add.py4
-rw-r--r--tests/functional/test_wallace/test_002_footer.py5
-rw-r--r--tests/functional/test_wallace/test_003_nonascii_subject.py8
-rw-r--r--tests/functional/test_wallace/test_004_nonascii_addresses.py8
-rw-r--r--tests/functional/test_wallace/test_005_resource_add.py11
-rw-r--r--tests/functional/test_wallace/test_005_resource_invitation.py243
-rw-r--r--tests/functional/test_wallace/test_006_resource_performance.py29
-rw-r--r--tests/functional/test_wallace/test_007_invitationpolicy.py172
-rw-r--r--tests/functional/test_wap_client/__init__.py1
-rw-r--r--tests/functional/test_wap_client/test_001_connect.py15
-rw-r--r--tests/functional/test_wap_client/test_002_user_add.py12
-rw-r--r--tests/functional/test_wap_client/test_003_user_add_fr_FR.py4
-rw-r--r--tests/functional/test_wap_client/test_004_user_add_es_ES.py4
-rw-r--r--tests/functional/test_wap_client/test_005_user_add_de_CH.py3
-rw-r--r--tests/functional/test_wap_client/test_006_form_value_select_options.py6
-rw-r--r--tests/functional/test_wap_client/test_007_policy_uid.py3
-rw-r--r--tests/functional/test_wap_client/test_008_resource_add.py3
-rw-r--r--tests/functional/user_add.py16
-rw-r--r--tests/unit/test-000-imports.py1
-rw-r--r--tests/unit/test-001-contact_reference.py3
-rw-r--r--tests/unit/test-002-attendee.py39
-rw-r--r--tests/unit/test-003-event.py60
-rw-r--r--tests/unit/test-004-icalendar.py11
-rw-r--r--tests/unit/test-005-timezone.py36
-rw-r--r--tests/unit/test-006-ldap_psearch.py1
-rw-r--r--tests/unit/test-007-ldap_syncrepl.py1
-rw-r--r--tests/unit/test-008-sievelib.py3
-rw-r--r--tests/unit/test-009-parse_ldap_uri.py3
-rw-r--r--tests/unit/test-010-transliterate.py1
-rw-r--r--tests/unit/test-011-itip.py97
-rw-r--r--tests/unit/test-011-wallace_resources.py39
-rw-r--r--tests/unit/test-012-wallace_invitationpolicy.py44
-rw-r--r--tests/unit/test-014-conf-and-raw.py3
-rw-r--r--tests/unit/test-015-translate.py1
-rw-r--r--tests/unit/test-016-todo.py12
-rw-r--r--tests/unit/test-017-diff.py6
-rw-r--r--tests/unit/test-018-note.py7
-rw-r--r--tests/unit/test-019-contact.py6
-rw-r--r--tests/unit/test-020-auth_cache.py6
-rwxr-xr-xucs/kolab_sieve.py22
-rwxr-xr-xucs/listener.py52
-rwxr-xr-xwallace.py1
60 files changed, 521 insertions, 572 deletions
diff --git a/conf.py b/conf.py
index c74a0ff..8e5ef43 100755
--- a/conf.py
+++ b/conf.py
@@ -22,7 +22,6 @@
Kolab configuration utility.
"""
-
import logging
import os
import sys
@@ -44,4 +43,3 @@ if __name__ == "__main__":
pykolab = pykolab.Conf()
pykolab.finalize_conf()
pykolab.run()
-
diff --git a/kolab-cli.py b/kolab-cli.py
index 760c902..fbcfac5 100755
--- a/kolab-cli.py
+++ b/kolab-cli.py
@@ -38,4 +38,3 @@ except ImportError, e:
if __name__ == "__main__":
kolab = Cli()
kolab.run()
-
diff --git a/kolabd.py b/kolabd.py
index 6ca2975..ef4500a 100755
--- a/kolabd.py
+++ b/kolabd.py
@@ -37,4 +37,3 @@ import kolabd
if __name__ == "__main__":
kolabd = kolabd.KolabDaemon()
kolabd.run()
-
diff --git a/kolabd/__init__.py b/kolabd/__init__.py
index b21bd80..586ce70 100644
--- a/kolabd/__init__.py
+++ b/kolabd/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2013 Kolab Systems AG (http://www.kolabsys.com)
+# Copyright 2010-2016 Kolab Systems AG (http://www.kolabsys.com)
#
# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
#
@@ -40,6 +40,7 @@ from process import KolabdProcess as Process
log = pykolab.getLogger('pykolab.daemon')
conf = pykolab.getConf()
+
class KolabDaemon(object):
def __init__(self):
"""
@@ -156,7 +157,6 @@ class KolabDaemon(object):
sys.exit(1)
-
# Set real and effective user if not the same as current.
if not user_uid == ruid:
log.debug(
@@ -217,8 +217,8 @@ class KolabDaemon(object):
except AttributeError, errmsg:
exitcode = 1
traceback.print_exc()
- print >> sys.stderr, _("Traceback occurred, please report a " + \
- "bug at https://issues.kolab.org")
+ print >> sys.stderr, _("Traceback occurred, please report a " +
+ "bug at https://issues.kolab.org")
except TypeError, errmsg:
exitcode = 1
@@ -228,8 +228,8 @@ class KolabDaemon(object):
except:
exitcode = 2
traceback.print_exc()
- print >> sys.stderr, _("Traceback occurred, please report a " + \
- "bug at https://issues.kolab.org")
+ print >> sys.stderr, _("Traceback occurred, please report a " +
+ "bug at https://issues.kolab.org")
sys.exit(exitcode)
@@ -276,8 +276,8 @@ class KolabDaemon(object):
domain_base_dn = primary_auth.domain_naming_context(primary_domain)
log.debug(_("Domain Base DN for domain %r is %r") % (primary_domain, domain_base_dn), level=8)
- if not domain_base_dn == None:
- if not domain_base_dn in domain_base_dns:
+ if domain_base_dn is not None:
+ if domain_base_dn not in domain_base_dns:
domain_base_dns.append(domain_base_dn)
primary_domain = primary_auth.primary_domain_for_naming_context(domain_base_dn)
primary_domains.append(primary_domain)
@@ -366,6 +366,6 @@ class KolabDaemon(object):
def write_pid(self):
pid = os.getpid()
- fp = open(conf.pidfile,'w')
+ fp = open(conf.pidfile, 'w')
fp.write("%d\n" % (pid))
fp.close()
diff --git a/kolabd/process.py b/kolabd/process.py
index 384c394..e4d93ba 100644
--- a/kolabd/process.py
+++ b/kolabd/process.py
@@ -27,6 +27,7 @@ from pykolab.translate import _
log = pykolab.getLogger('pykolab.daemon')
conf = pykolab.getConf()
+
class KolabdProcess(multiprocessing.Process):
def __init__(self, domain):
self.domain = domain
@@ -42,7 +43,7 @@ class KolabdProcess(multiprocessing.Process):
log.debug(_("Synchronizing for domain %s") % (domain), level=8)
sync_interval = conf.get('kolab', 'sync_interval')
- if sync_interval == None or sync_interval == 0:
+ if sync_interval is None or sync_interval == 0:
sync_interval = 300
else:
sync_interval = (int)(sync_interval)
diff --git a/saslauthd.py b/saslauthd.py
index 8db7c58..9d4beab 100755
--- a/saslauthd.py
+++ b/saslauthd.py
@@ -39,4 +39,3 @@ import saslauthd
if __name__ == "__main__":
saslauthd = saslauthd.SASLAuthDaemon()
saslauthd.run()
-
diff --git a/saslauthd/__init__.py b/saslauthd/__init__.py
index c5d9cfa..2cb76d6 100644
--- a/saslauthd/__init__.py
+++ b/saslauthd/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2013 Kolab Systems AG (http://www.kolabsys.com)
+# Copyright 2010-2016 Kolab Systems AG (http://www.kolabsys.com)
#
# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
#
@@ -46,6 +46,7 @@ from pykolab.translate import _
log = pykolab.getLogger('saslauthd')
conf = pykolab.getConf()
+
class SASLAuthDaemon(object):
def __init__(self):
daemon_group = conf.add_cli_parser_option_group(_("Daemon Options"))
@@ -166,7 +167,8 @@ class SASLAuthDaemon(object):
except AttributeError, e:
exitcode = 1
traceback.print_exc()
- print >> sys.stderr, _("Traceback occurred, please report a bug at https://issues.kolab.org")
+ print >> sys.stderr, _("Traceback occurred, please report a " +
+ "bug at https://issues.kolab.org")
except TypeError, e:
exitcode = 1
traceback.print_exc()
@@ -174,7 +176,8 @@ class SASLAuthDaemon(object):
except:
exitcode = 2
traceback.print_exc()
- print >> sys.stderr, _("Traceback occurred, please report a bug at https://issues.kolab.org")
+ print >> sys.stderr, _("Traceback occurred, please report a " +
+ "bug at https://issues.kolab.org")
sys.exit(exitcode)
@@ -214,8 +217,8 @@ class SASLAuthDaemon(object):
bound = True
except Exception, errmsg:
log.error(
- _("kolab-saslauthd could not accept " + \
- "connections on socket: %r") % (errmsg)
+ _("kolab-saslauthd could not accept " +
+ "connections on socket: %r") % (errmsg)
)
if cur_tries >= max_tries:
@@ -288,7 +291,7 @@ class SASLAuthDaemon(object):
def write_pid(self):
pid = os.getpid()
- fp = open(conf.pidfile,'w')
+ fp = open(conf.pidfile, 'w')
fp.write("%d\n" % (pid))
fp.close()
@@ -358,7 +361,6 @@ class SASLAuthDaemon(object):
sys.exit(1)
-
# Set real and effective user if not the same as current.
if not user_uid == ruid:
log.debug(
diff --git a/test-wallace.py b/test-wallace.py
index 7ba7ac6..92d69f4 100755
--- a/test-wallace.py
+++ b/test-wallace.py
@@ -31,6 +31,7 @@ from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
+
def send_mail(send_from, send_to, send_with=None):
smtp = smtplib.SMTP("localhost", 10026)
smtp.set_debuglevel(True)
@@ -57,7 +58,7 @@ Lucy Meier.
msg.attach( MIMEText(text) )
- #msg.attach( MIMEBase('application', open('/boot/initrd-plymouth.img').read()) )
+ # msg.attach( MIMEBase('application', open('/boot/initrd-plymouth.img').read()) )
smtp.sendmail(send_from, send_to, msg.as_string())
diff --git a/tests/functional/purge_imap.py b/tests/functional/purge_imap.py
index 67d4aec..f4d62e0 100644
--- a/tests/functional/purge_imap.py
+++ b/tests/functional/purge_imap.py
@@ -7,6 +7,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
def purge_imap():
time.sleep(2)
diff --git a/tests/functional/purge_users.py b/tests/functional/purge_users.py
index 17db9d7..713ea46 100644
--- a/tests/functional/purge_users.py
+++ b/tests/functional/purge_users.py
@@ -6,6 +6,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
def purge_users():
wap_client.authenticate(conf.get("ldap", "bind_dn"), conf.get("ldap", "bind_pw"))
diff --git a/tests/functional/resource_func.py b/tests/functional/resource_func.py
index a7e4d90..36bd1bd 100644
--- a/tests/functional/resource_func.py
+++ b/tests/functional/resource_func.py
@@ -4,11 +4,12 @@ from pykolab import wap_client
conf = pykolab.getConf()
+
def resource_add(type, cn, members=None, owner=None, **kw):
- if type == None or type == '':
+ if type is None or type == '':
raise Exception
- if cn == None or cn == '':
+ if cn is None or cn == '':
raise Exception
resource_details = {
@@ -21,7 +22,10 @@ def resource_add(type, cn, members=None, owner=None, **kw):
resource_details.update(kw)
- result = wap_client.authenticate(conf.get('ldap', 'bind_dn'), conf.get('ldap', 'bind_pw'), conf.get('kolab', 'primary_domain'))
+ bind_dn = conf.get('ldap', 'bind_dn')
+ bind_pw = conf.get('ldap', 'bind_pw')
+ domain = conf.get('kolab', 'primary_domain')
+ result = wap_client.authenticate(bind_dn, bind_pw, domain)
type_id = 0
resource_types = wap_client.resource_types_list()
@@ -41,7 +45,7 @@ def resource_add(type, cn, members=None, owner=None, **kw):
attr_details = resource_type_info['form_fields'][attribute]
if isinstance(attr_details, dict):
- if not attr_details.has_key('optional') or attr_details['optional'] == False or resource_details.has_key(attribute):
+ if 'optional' not in attr_details or attr_details['optional'] is False or attribute in resource_details:
params[attribute] = resource_details[attribute]
elif isinstance(attr_details, list):
params[attribute] = resource_details[attribute]
@@ -49,7 +53,7 @@ def resource_add(type, cn, members=None, owner=None, **kw):
fvg_params = params
fvg_params['object_type'] = 'resource'
fvg_params['type_id'] = type_id
- fvg_params['attributes'] = [attr for attr in resource_type_info['auto_form_fields'].keys() if not attr in params.keys()]
+ fvg_params['attributes'] = [attr for attr in resource_type_info['auto_form_fields'].keys() if attr not in params]
result = wap_client.resource_add(params)
result['dn'] = "cn=" + result['cn'] + ",ou=Resources,dc=example,dc=org"
@@ -57,13 +61,15 @@ def resource_add(type, cn, members=None, owner=None, **kw):
def purge_resources():
- wap_client.authenticate(conf.get("ldap", "bind_dn"), conf.get("ldap", "bind_pw"), conf.get('kolab', 'primary_domain'))
+ bind_dn = conf.get('ldap', 'bind_dn')
+ bind_pw = conf.get('ldap', 'bind_pw')
+ domain = conf.get('kolab', 'primary_domain')
+ result = wap_client.authenticate(bind_dn, bind_pw, domain)
resources = wap_client.resources_list()
for resource in resources['list']:
wap_client.resource_delete({'id': resource})
- #from tests.functional.purge_imap import purge_imap
- #purge_imap()
-
+ # from tests.functional.purge_imap import purge_imap
+ # purge_imap()
diff --git a/tests/functional/synchronize.py b/tests/functional/synchronize.py
index 7046db2..428ea74 100644
--- a/tests/functional/synchronize.py
+++ b/tests/functional/synchronize.py
@@ -1,5 +1,6 @@
from pykolab.auth import Auth
+
def synchronize_once():
auth = Auth()
auth.connect()
diff --git a/tests/functional/test_kolabd/__init__.py b/tests/functional/test_kolabd/__init__.py
index d7bf27f..d6cdb57 100644
--- a/tests/functional/test_kolabd/__init__.py
+++ b/tests/functional/test_kolabd/__init__.py
@@ -1,5 +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
index 671188a..e8c804d 100644
--- a/tests/functional/test_kolabd/test_001_user_sync.py
+++ b/tests/functional/test_kolabd/test_001_user_sync.py
@@ -8,6 +8,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestKolabDaemon(unittest.TestCase):
@classmethod
def setup_class(self, *args, **kw):
@@ -61,7 +62,7 @@ class TestKolabDaemon(unittest.TestCase):
result = wap_client.user_info(recipient)
- if not result.has_key('mailhost'):
+ if 'mailhost' not in result:
from tests.functional.synchronize import synchronize_once
synchronize_once()
@@ -106,14 +107,14 @@ class TestKolabDaemon(unittest.TestCase):
print metadata
folder_name = '/'.join(folder.split('/')[2:]).split('@')[0]
- if ac_folders.has_key(folder_name):
- if ac_folders[folder_name].has_key('annotations'):
+ if folder_name in ac_folders:
+ if 'annotations' in ac_folders[folder_name]:
for _annotation in ac_folders[folder_name]['annotations'].keys():
if _annotation.startswith('/private'):
continue
_annotation_value = ac_folders[folder_name]['annotations'][_annotation]
- self.assertTrue(metadata[metadata.keys().pop()].has_key(_annotation))
+ self.assertTrue(_annotation in metadata[metadata.keys().pop()])
self.assertEqual(_annotation_value, metadata[metadata.keys().pop()][_annotation])
def test_006_user_subscriptions(self):
@@ -137,4 +138,3 @@ class TestKolabDaemon(unittest.TestCase):
def test_013_resource_mailbox_annotation(self):
pass
-
diff --git a/tests/functional/test_kolabd/test_002_user_rename.py b/tests/functional/test_kolabd/test_002_user_rename.py
index f526ade..3ac4a02 100644
--- a/tests/functional/test_kolabd/test_002_user_rename.py
+++ b/tests/functional/test_kolabd/test_002_user_rename.py
@@ -8,6 +8,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestKolabDaemon(unittest.TestCase):
@classmethod
def setup_class(self, *args, **kw):
@@ -39,7 +40,7 @@ class TestKolabDaemon(unittest.TestCase):
recipient = auth.find_recipient('john.doe@example.org')
user_info = wap_client.user_info(recipient)
- if not user_info.has_key('mailhost'):
+ if 'mailhost' not in user_info:
from tests.functional.synchronize import synchronize_once
synchronize_once()
@@ -77,4 +78,3 @@ class TestKolabDaemon(unittest.TestCase):
folders = imap.lm('user/joe.sixpack@example.org')
self.assertEqual(len(folders), 1, "INBOX for joe.sixpack does not exist")
-
diff --git a/tests/functional/test_kolabd/test_003_two_johns.py b/tests/functional/test_kolabd/test_003_two_johns.py
index b2bfb46..0f93969 100644
--- a/tests/functional/test_kolabd/test_003_two_johns.py
+++ b/tests/functional/test_kolabd/test_003_two_johns.py
@@ -8,6 +8,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestKolabDaemon(unittest.TestCase):
@classmethod
def setup_class(self, *args, **kw):
@@ -48,4 +49,3 @@ class TestKolabDaemon(unittest.TestCase):
folders = imap.lm('user/john.doe2@example.org')
self.assertEqual(len(folders), 1, "No INBOX found for second John")
-
diff --git a/tests/functional/test_postfix/__init__.py b/tests/functional/test_postfix/__init__.py
index d7bf27f..d6cdb57 100644
--- a/tests/functional/test_postfix/__init__.py
+++ b/tests/functional/test_postfix/__init__.py
@@ -1,5 +1,6 @@
import pykolab
+
def setup_package():
conf = pykolab.getConf()
conf.finalize_conf(fatal=False)
diff --git a/tests/functional/test_wallace/__init__.py b/tests/functional/test_wallace/__init__.py
index d7bf27f..d6cdb57 100644
--- a/tests/functional/test_wallace/__init__.py
+++ b/tests/functional/test_wallace/__init__.py
@@ -1,5 +1,6 @@
import pykolab
+
def setup_package():
conf = pykolab.getConf()
conf.finalize_conf(fatal=False)
diff --git a/tests/functional/test_wallace/test_001_user_add.py b/tests/functional/test_wallace/test_001_user_add.py
index d4e620a..a6945c9 100644
--- a/tests/functional/test_wallace/test_001_user_add.py
+++ b/tests/functional/test_wallace/test_001_user_add.py
@@ -1,4 +1,3 @@
-
from email import message_from_string
import time
@@ -11,6 +10,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestUserAdd(unittest.TestCase):
@classmethod
@@ -45,7 +45,7 @@ class TestUserAdd(unittest.TestCase):
folders = imap.lm('user/%(local)s@%(domain)s' % (self.john))
self.assertEqual(len(folders), 1)
-
+
folders = imap.lm('user/%(local)s@%(domain)s' % (self.jane))
self.assertEqual(len(folders), 1)
diff --git a/tests/functional/test_wallace/test_002_footer.py b/tests/functional/test_wallace/test_002_footer.py
index 4c1599c..d6e5836 100644
--- a/tests/functional/test_wallace/test_002_footer.py
+++ b/tests/functional/test_wallace/test_002_footer.py
@@ -17,6 +17,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestWallaceFooter(unittest.TestCase):
user = None
@@ -115,10 +116,10 @@ class TestWallaceFooter(unittest.TestCase):
def send_message(self, msg, _to=None, _from=None):
smtp = smtplib.SMTP('localhost', 10026)
- if _to == None:
+ if _to is None:
_to = self.send_to
- if _from == None:
+ if _from is None:
_from = self.send_from
smtp.sendmail(_from, _to, msg.as_string())
diff --git a/tests/functional/test_wallace/test_003_nonascii_subject.py b/tests/functional/test_wallace/test_003_nonascii_subject.py
index ff21aee..87d163a 100644
--- a/tests/functional/test_wallace/test_003_nonascii_subject.py
+++ b/tests/functional/test_wallace/test_003_nonascii_subject.py
@@ -19,6 +19,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestWallaceNonASCIISubject(unittest.TestCase):
@classmethod
@@ -83,10 +84,10 @@ class TestWallaceNonASCIISubject(unittest.TestCase):
def send_message(self, msg, _to=None, _from=None):
smtp = smtplib.SMTP('localhost', 10026)
- if _to == None:
+ if _to is None:
_to = self.send_to
- if _from == None:
+ if _from is None:
_from = self.send_from
smtp.sendmail(_from, _to, msg.as_string())
@@ -97,7 +98,7 @@ class TestWallaceNonASCIISubject(unittest.TestCase):
folders = imap.lm('user/%(local)s@%(domain)s' % (self.user))
self.assertEqual(len(folders), 1)
-
+
def test_002_send_nonascii_subject(self):
subject = Header(u"test_002_nonascii_subject chwała")
body = "This is a test message"
@@ -123,4 +124,3 @@ class TestWallaceNonASCIISubject(unittest.TestCase):
if not self.check_message_delivered(subject):
raise Exception
-
diff --git a/tests/functional/test_wallace/test_004_nonascii_addresses.py b/tests/functional/test_wallace/test_004_nonascii_addresses.py
index 45df30e..42239c4 100644
--- a/tests/functional/test_wallace/test_004_nonascii_addresses.py
+++ b/tests/functional/test_wallace/test_004_nonascii_addresses.py
@@ -19,6 +19,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestWallaceNonASCIIAddresses(unittest.TestCase):
@classmethod
@@ -83,10 +84,10 @@ class TestWallaceNonASCIIAddresses(unittest.TestCase):
def send_message(self, msg, _to=None, _from=None):
smtp = smtplib.SMTP('localhost', 10026)
- if _to == None:
+ if _to is None:
_to = self.send_to
- if _from == None:
+ if _from is None:
_from = self.send_from
smtp.sendmail(_from, _to, msg.as_string())
@@ -97,7 +98,7 @@ class TestWallaceNonASCIIAddresses(unittest.TestCase):
folders = imap.lm('user/%(local)s@%(domain)s' % (self.user))
self.assertEqual(len(folders), 1)
-
+
def test_002_send_nonascii_addresses(self):
subject = Header(u"test_002_nonascii_addresses")
body = "This is a test message"
@@ -123,4 +124,3 @@ class TestWallaceNonASCIIAddresses(unittest.TestCase):
if not self.check_message_delivered(subject):
raise Exception
-
diff --git a/tests/functional/test_wallace/test_005_resource_add.py b/tests/functional/test_wallace/test_005_resource_add.py
index fc7f3ed..a378d9c 100644
--- a/tests/functional/test_wallace/test_005_resource_add.py
+++ b/tests/functional/test_wallace/test_005_resource_add.py
@@ -11,12 +11,13 @@ import tests.functional.resource_func as funcs
conf = pykolab.getConf()
+
class TestResourceAdd(unittest.TestCase):
@classmethod
def setUp(self):
from tests.functional.purge_users import purge_users
- #purge_users()
+ # purge_users()
self.john = {
'local': 'john.doe',
@@ -24,13 +25,13 @@ class TestResourceAdd(unittest.TestCase):
}
from tests.functional.user_add import user_add
- #user_add("John", "Doe")
+ # user_add("John", "Doe")
funcs.purge_resources()
self.audi = funcs.resource_add("car", "Audi A4")
self.passat = funcs.resource_add("car", "VW Passat")
self.boxter = funcs.resource_add("car", "Porsche Boxter S", kolabinvitationpolicy='ACT_ACCEPT_AND_NOTIFY')
- self.cars = funcs.resource_add("collection", "Company Cars", [ self.audi['dn'], self.passat['dn'], self.boxter['dn'] ], kolabinvitationpolicy='ACT_ACCEPT')
+ self.cars = funcs.resource_add("collection", "Company Cars", [self.audi['dn'], self.passat['dn'], self.boxter['dn']], kolabinvitationpolicy='ACT_ACCEPT')
from tests.functional.synchronize import synchronize_once
synchronize_once()
@@ -38,8 +39,8 @@ class TestResourceAdd(unittest.TestCase):
@classmethod
def tearDown(self):
from tests.functional.purge_users import purge_users
- #funcs.purge_resources()
- #purge_users()
+ # funcs.purge_resources()
+ # purge_users()
def test_001_resource_created(self):
resource = module_resources.resource_record_from_email_address(self.audi['mail'])
diff --git a/tests/functional/test_wallace/test_005_resource_invitation.py b/tests/functional/test_wallace/test_005_resource_invitation.py
index af84fa6..5429331 100644
--- a/tests/functional/test_wallace/test_005_resource_invitation.py
+++ b/tests/functional/test_wallace/test_005_resource_invitation.py
@@ -131,7 +131,6 @@ END:VEVENT
END:VCALENDAR
"""
-
itip_recurring = """
BEGIN:VCALENDAR
VERSION:2.0
@@ -178,8 +177,8 @@ Content-Transfer-Encoding: 8bit
--=_c8894dbdb8baeedacae836230e3436fd--
"""
-class TestResourceInvitation(unittest.TestCase):
+class TestResourceInvitation(unittest.TestCase):
john = None
@classmethod
@@ -192,7 +191,7 @@ class TestResourceInvitation(unittest.TestCase):
@classmethod
def setup_class(self, *args, **kw):
# set language to default
- pykolab.translate.setUserLanguage(conf.get('kolab','default_locale'))
+ pykolab.translate.setUserLanguage(conf.get('kolab', 'default_locale'))
self.itip_reply_subject = _("Reservation Request for %(summary)s was %(status)s")
@@ -223,14 +222,14 @@ class TestResourceInvitation(unittest.TestCase):
self.audi = funcs.resource_add("car", "Audi A4")
self.passat = funcs.resource_add("car", "VW Passat")
self.boxter = funcs.resource_add("car", "Porsche Boxter S")
- self.cars = funcs.resource_add("collection", "Company Cars", [ self.audi['dn'], self.passat['dn'], self.boxter['dn'] ])
+ self.cars = funcs.resource_add("collection", "Company Cars", [self.audi['dn'], self.passat['dn'], self.boxter['dn']])
self.room1 = funcs.resource_add("confroom", "Room 101", owner=self.jane['dn'], kolabinvitationpolicy='ACT_ACCEPT_AND_NOTIFY')
self.room2 = funcs.resource_add("confroom", "Conference Room B-222")
- self.rooms = funcs.resource_add("collection", "Rooms", [ self.room1['dn'], self.room2['dn'] ], self.jane['dn'], kolabinvitationpolicy='ACT_ACCEPT_AND_NOTIFY')
+ self.rooms = funcs.resource_add("collection", "Rooms", [self.room1['dn'], self.room2['dn']], self.jane['dn'], kolabinvitationpolicy='ACT_ACCEPT_AND_NOTIFY')
self.room3 = funcs.resource_add("confroom", "CEOs Office 303")
- self.viprooms = funcs.resource_add("collection", "VIP Rooms", [ self.room3['dn'] ], self.jane['dn'], kolabinvitationpolicy='ACT_MANUAL')
+ self.viprooms = funcs.resource_add("collection", "VIP Rooms", [self.room3['dn']], self.jane['dn'], kolabinvitationpolicy='ACT_MANUAL')
time.sleep(1)
from tests.functional.synchronize import synchronize_once
@@ -315,16 +314,16 @@ class TestResourceInvitation(unittest.TestCase):
return uid
-
def send_owner_response(self, event, partstat, from_addr=None):
if from_addr is None:
from_addr = self.jane['mail']
- itip_reply = event.to_message_itip(from_addr,
- method="REPLY",
- participant_status=partstat,
- message_text="Request " + partstat,
- subject="Booking has been %s" % (partstat)
+ itip_reply = event.to_message_itip(
+ from_addr,
+ method="REPLY",
+ participant_status=partstat,
+ message_text="Request " + partstat,
+ subject="Booking has been %s" % (partstat)
)
smtp = smtplib.SMTP('localhost', 10026)
@@ -405,7 +404,6 @@ class TestResourceInvitation(unittest.TestCase):
imap.imap.m.expunge()
imap.disconnect()
-
def find_resource_by_email(self, email):
resource = None
for r in [self.audi, self.passat, self.boxter, self.room1, self.room2]:
@@ -414,7 +412,6 @@ class TestResourceInvitation(unittest.TestCase):
break
return resource
-
def test_001_resource_from_email_address(self):
resource = module_resources.resource_record_from_email_address(self.audi['mail'])
self.assertEqual(len(resource), 1)
@@ -424,35 +421,32 @@ class TestResourceInvitation(unittest.TestCase):
self.assertEqual(len(collection), 1)
self.assertEqual(collection[0], self.cars['dn'])
-
def test_002_invite_resource(self):
- uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,7,13, 10,0,0))
+ uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 7, 13, 10, 0, 0))
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.audi['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.audi['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_resource_calendar_event(self.audi['kolabtargetfolder'], uid)
self.assertIsInstance(event, pykolab.xml.Event)
self.assertEqual(event.get_summary(), "test")
-
# @depends test_002_invite_resource
def test_003_invite_resource_conflict(self):
- uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,7,13, 12,0,0))
+ uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 7, 13, 12, 0, 0))
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DECLINED') }, self.audi['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DECLINED')}, self.audi['mail'])
self.assertIsInstance(response, email.message.Message)
self.assertEqual(self.check_resource_calendar_event(self.audi['kolabtargetfolder'], uid), None)
-
def test_004_invite_resource_collection(self):
self.purge_mailbox(self.john['mailbox'])
- uid = self.send_itip_invitation(self.cars['mail'], datetime.datetime(2014,7,13, 12,0,0))
+ uid = self.send_itip_invitation(self.cars['mail'], datetime.datetime(2014, 7, 13, 12, 0, 0))
# one of the collection members accepted the reservation
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
self.assertIsInstance(accept, email.message.Message)
delegatee = self.find_resource_by_email(accept['from'])
@@ -462,23 +456,22 @@ class TestResourceInvitation(unittest.TestCase):
self.assertIsInstance(self.check_resource_calendar_event(delegatee['kolabtargetfolder'], uid), pykolab.xml.Event)
# resource collection responds with a DELEGATED message
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DELEGATED') }, self.cars['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DELEGATED')}, self.cars['mail'])
self.assertIsInstance(response, email.message.Message)
self.assertIn("ROLE=NON-PARTICIPANT;RSVP=FALSE", str(response))
-
def test_005_rescheduling_reservation(self):
self.purge_mailbox(self.john['mailbox'])
- uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,4,1, 10,0,0))
+ uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 4, 1, 10, 0, 0))
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.audi['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.audi['mail'])
self.assertIsInstance(response, email.message.Message)
self.purge_mailbox(self.john['mailbox'])
- self.send_itip_update(self.audi['mail'], uid, datetime.datetime(2014,4,1, 12,0,0)) # conflict with myself
+ self.send_itip_update(self.audi['mail'], uid, datetime.datetime(2014, 4, 1, 12, 0, 0)) # conflict with myself
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.audi['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.audi['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_resource_calendar_event(self.audi['kolabtargetfolder'], uid)
@@ -486,28 +479,27 @@ class TestResourceInvitation(unittest.TestCase):
self.assertEqual(event.get_start().hour, 12)
self.assertEqual(event.get_sequence(), 2)
-
def test_005_rescheduling_collection(self):
self.purge_mailbox(self.john['mailbox'])
- uid = self.send_itip_invitation(self.cars['mail'], datetime.datetime(2014,4,24, 12,0,0))
+ uid = self.send_itip_invitation(self.cars['mail'], datetime.datetime(2014, 4, 24, 12, 0, 0))
# one of the collection members accepted the reservation
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
self.assertIsInstance(accept, email.message.Message)
delegatee = self.find_resource_by_email(accept['from'])
# book that resource for the next day
- self.send_itip_invitation(delegatee['mail'], datetime.datetime(2014,4,25, 14,0,0))
- accept2 = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ self.send_itip_invitation(delegatee['mail'], datetime.datetime(2014, 4, 25, 14, 0, 0))
+ accept2 = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
# re-schedule first booking to a conflicting date
self.purge_mailbox(self.john['mailbox'])
update_template = itip_delegated.replace("resource-car-audia4@example.org", delegatee['mail'])
- self.send_itip_update(delegatee['mail'], uid, datetime.datetime(2014,4,25, 12,0,0), template=update_template)
+ self.send_itip_update(delegatee['mail'], uid, datetime.datetime(2014, 4, 25, 12, 0, 0), template=update_template)
# expect response from another member of the initially delegated collection
- new_accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ new_accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
self.assertIsInstance(new_accept, email.message.Message)
new_delegatee = self.find_resource_by_email(new_accept['from'])
@@ -518,17 +510,16 @@ class TestResourceInvitation(unittest.TestCase):
self.assertIsInstance(event, pykolab.xml.Event)
# old resource responds with a DELEGATED message
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DELEGATED') }, delegatee['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DELEGATED')}, delegatee['mail'])
self.assertIsInstance(response, email.message.Message)
# old reservation was removed from old delegate's calendar
self.assertEqual(self.check_resource_calendar_event(delegatee['kolabtargetfolder'], uid), None)
-
def test_006_cancelling_revervation(self):
self.purge_mailbox(self.john['mailbox'])
- uid = self.send_itip_invitation(self.boxter['mail'], datetime.datetime(2014,5,1, 10,0,0))
+ uid = self.send_itip_invitation(self.boxter['mail'], datetime.datetime(2014, 5, 1, 10, 0, 0))
self.assertIsInstance(self.check_resource_calendar_event(self.boxter['kolabtargetfolder'], uid), pykolab.xml.Event)
self.send_itip_cancel(self.boxter['mail'], uid)
@@ -537,20 +528,19 @@ class TestResourceInvitation(unittest.TestCase):
self.assertEqual(self.check_resource_calendar_event(self.boxter['kolabtargetfolder'], uid), None)
# make new reservation to the now free'd slot
- self.send_itip_invitation(self.boxter['mail'], datetime.datetime(2014,5,1, 9,0,0))
+ self.send_itip_invitation(self.boxter['mail'], datetime.datetime(2014, 5, 1, 9, 0, 0))
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.boxter['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.boxter['mail'])
self.assertIsInstance(response, email.message.Message)
-
def test_007_update_delegated(self):
self.purge_mailbox(self.john['mailbox'])
- dt = datetime.datetime(2014,8,1, 12,0,0)
+ dt = datetime.datetime(2014, 8, 1, 12, 0, 0)
uid = self.send_itip_invitation(self.cars['mail'], dt)
# wait for accept notification
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
self.assertIsInstance(accept, email.message.Message)
delegatee = self.find_resource_by_email(accept['from'])
@@ -561,97 +551,91 @@ class TestResourceInvitation(unittest.TestCase):
self.send_itip_update(delegatee['mail'], uid, dt, template=update_template)
# get response from delegatee
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
self.assertIsInstance(accept, email.message.Message)
self.assertIn(delegatee['mail'], accept['from'])
# no delegation response on updates
- self.assertEqual(self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DELEGATED') }, self.cars['mail']), None)
-
+ self.assertEqual(self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DELEGATED')}, self.cars['mail']), None)
def test_008_allday_reservation(self):
self.purge_mailbox(self.john['mailbox'])
- uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,6,2), True)
+ uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 6, 2), True)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
self.assertIsInstance(accept, email.message.Message)
event = self.check_resource_calendar_event(self.audi['kolabtargetfolder'], uid)
self.assertIsInstance(event, pykolab.xml.Event)
self.assertIsInstance(event.get_start(), datetime.date)
- uid2 = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,6,2, 16,0,0))
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DECLINED') }, self.audi['mail'])
+ uid2 = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 6, 2, 16, 0, 0))
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DECLINED')}, self.audi['mail'])
self.assertIsInstance(response, email.message.Message)
-
def test_009_recurring_events(self):
self.purge_mailbox(self.john['mailbox'])
# register an infinitely recurring resource invitation
- uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,2,20, 12,0,0),
+ uid = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 2, 20, 12, 0, 0),
template=itip_recurring.replace(";COUNT=10", ""))
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
self.assertIsInstance(accept, email.message.Message)
# check non-recurring against recurring
- uid2 = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,3,13, 10,0,0))
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DECLINED') }, self.audi['mail'])
+ uid2 = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 3, 13, 10, 0, 0))
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DECLINED')}, self.audi['mail'])
self.assertIsInstance(response, email.message.Message)
self.purge_mailbox(self.john['mailbox'])
# check recurring against recurring
- uid3 = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,2,22, 8,0,0), template=itip_recurring)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ uid3 = self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 2, 22, 8, 0, 0), template=itip_recurring)
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
self.assertIsInstance(accept, email.message.Message)
-
def test_010_invalid_bookings(self):
self.purge_mailbox(self.john['mailbox'])
itip_other = itip_invitation.replace("mailto:%s", "mailto:some-other-resource@example.org\nCOMMENT: Sent to %s")
- self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,3,22, 8,0,0), template=itip_other)
+ self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 3, 22, 8, 0, 0), template=itip_other)
time.sleep(1)
itip_invalid = itip_invitation.replace("DTSTART;", "X-DTSTART;")
- self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014,3,24, 19,30,0), template=itip_invalid)
-
- self.assertEqual(self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.audi['mail']), None)
+ self.send_itip_invitation(self.audi['mail'], datetime.datetime(2014, 3, 24, 19, 30, 0), template=itip_invalid)
+ self.assertEqual(self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.audi['mail']), None)
def test_011_owner_info(self):
self.purge_mailbox(self.john['mailbox'])
- self.send_itip_invitation(self.room1['mail'], datetime.datetime(2014,6,19, 16,0,0))
+ self.send_itip_invitation(self.room1['mail'], datetime.datetime(2014, 6, 19, 16, 0, 0))
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.room1['mail'])
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.room1['mail'])
self.assertIsInstance(accept, email.message.Message)
respose_text = str(accept.get_payload(0))
self.assertIn(self.jane['mail'], respose_text)
self.assertIn(self.jane['displayname'], respose_text)
-
def test_011_owner_info_from_collection(self):
self.purge_mailbox(self.john['mailbox'])
- self.send_itip_invitation(self.room2['mail'], datetime.datetime(2014,6,19, 16,0,0))
+ self.send_itip_invitation(self.room2['mail'], datetime.datetime(2014, 6, 19, 16, 0, 0))
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.room2['mail'])
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.room2['mail'])
self.assertIsInstance(accept, email.message.Message)
respose_text = str(accept.get_payload(0))
self.assertIn(self.jane['mail'], respose_text)
self.assertIn(self.jane['displayname'], respose_text)
-
def test_012_owner_notification(self):
self.purge_mailbox(self.john['mailbox'])
self.purge_mailbox(self.jane['mailbox'])
- self.send_itip_invitation(self.room1['mail'], datetime.datetime(2014,8,4, 13,0,0))
+ self.send_itip_invitation(self.room1['mail'], datetime.datetime(2014, 8, 4, 13, 0, 0))
# check notification message sent to resource owner (jane)
notify = self.check_message_received(_('Booking for %s has been %s') % (self.room1['cn'], participant_status_label('ACCEPTED')), self.room1['mail'], self.jane['mailbox'])
@@ -664,25 +648,24 @@ class TestResourceInvitation(unittest.TestCase):
self.purge_mailbox(self.john['mailbox'])
# check notification sent to collection owner (jane)
- self.send_itip_invitation(self.rooms['mail'], datetime.datetime(2014,8,4, 12,30,0))
+ self.send_itip_invitation(self.rooms['mail'], datetime.datetime(2014, 8, 4, 12, 30, 0))
# one of the collection members accepted the reservation
- accepted = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accepted = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')})
delegatee = self.find_resource_by_email(accepted['from'])
notify = self.check_message_received(_('Booking for %s has been %s') % (delegatee['cn'], participant_status_label('ACCEPTED')), delegatee['mail'], self.jane['mailbox'])
self.assertIsInstance(notify, email.message.Message)
self.assertIn(self.john['mail'], notification_text)
-
def test_013_owner_confirmation_accept(self):
self.purge_mailbox(self.john['mailbox'])
self.purge_mailbox(self.jane['mailbox'])
- uid = self.send_itip_invitation(self.room3['mail'], datetime.datetime(2014,9,12, 14,0,0))
+ uid = self.send_itip_invitation(self.room3['mail'], datetime.datetime(2014, 9, 12, 14, 0, 0))
# requester (john) gets a TENTATIVE confirmation
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('TENTATIVE') }, self.room3['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('TENTATIVE')}, self.room3['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_resource_calendar_event(self.room3['kolabtargetfolder'], uid)
@@ -699,7 +682,7 @@ class TestResourceInvitation(unittest.TestCase):
self.send_owner_response(itip_event['xml'], 'ACCEPTED', from_addr=self.jane['mail'])
# requester (john) now gets the ACCEPTED response
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.room3['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.room3['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_resource_calendar_event(self.room3['kolabtargetfolder'], uid)
@@ -707,15 +690,14 @@ class TestResourceInvitation(unittest.TestCase):
self.assertEqual(event.get_status(True), 'CONFIRMED')
self.assertEqual(event.get_attendee_by_email(self.room3['mail']).get_participant_status(True), 'ACCEPTED')
-
def test_014_owner_confirmation_decline(self):
self.purge_mailbox(self.john['mailbox'])
self.purge_mailbox(self.jane['mailbox'])
- uid = self.send_itip_invitation(self.room3['mail'], datetime.datetime(2014,9,14, 9,0,0))
+ uid = self.send_itip_invitation(self.room3['mail'], datetime.datetime(2014, 9, 14, 9, 0, 0))
# requester (john) gets a TENTATIVE confirmation
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('TENTATIVE') }, self.room3['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('TENTATIVE')}, self.room3['mail'])
self.assertIsInstance(response, email.message.Message)
# check confirmation message sent to resource owner (jane)
@@ -725,11 +707,12 @@ class TestResourceInvitation(unittest.TestCase):
itip_event = events_from_message(notify)[0]
# resource owner declines reservation request
- itip_reply = itip_event['xml'].to_message_itip(self.jane['mail'],
- method="REPLY",
- participant_status='DECLINED',
- message_text="Request declined",
- subject=_('Booking for %s has been %s') % (self.room3['cn'], participant_status_label('DECLINED'))
+ itip_reply = itip_event['xml'].to_message_itip(
+ self.jane['mail'],
+ method="REPLY",
+ participant_status='DECLINED',
+ message_text="Request declined",
+ subject=_('Booking for %s has been %s') % (self.room3['cn'], participant_status_label('DECLINED'))
)
smtp = smtplib.SMTP('localhost', 10026)
@@ -737,23 +720,22 @@ class TestResourceInvitation(unittest.TestCase):
smtp.quit()
# requester (john) now gets the DECLINED response
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DECLINED') }, self.room3['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DECLINED')}, self.room3['mail'])
self.assertIsInstance(response, email.message.Message)
# tentative reservation was set to cancelled
event = self.check_resource_calendar_event(self.room3['kolabtargetfolder'], uid)
self.assertEqual(event, None)
- #self.assertEqual(event.get_status(True), 'CANCELLED')
- #self.assertEqual(event.get_attendee_by_email(self.room3['mail']).get_participant_status(True), 'DECLINED')
-
+ # self.assertEqual(event.get_status(True), 'CANCELLED')
+ # self.assertEqual(event.get_attendee_by_email(self.room3['mail']).get_participant_status(True), 'DECLINED')
def test_015_owner_confirmation_update(self):
self.purge_mailbox(self.john['mailbox'])
- uid = self.send_itip_invitation(self.room3['mail'], datetime.datetime(2014,8,19, 9,0,0), uid="http://a-totally.stupid/?uid")
+ uid = self.send_itip_invitation(self.room3['mail'], datetime.datetime(2014, 8, 19, 9, 0, 0), uid="http://a-totally.stupid/?uid")
# requester (john) gets a TENTATIVE confirmation
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('TENTATIVE') }, self.room3['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('TENTATIVE')}, self.room3['mail'])
self.assertIsInstance(response, email.message.Message)
# check first confirmation message sent to resource owner (jane)
@@ -767,7 +749,7 @@ class TestResourceInvitation(unittest.TestCase):
self.purge_mailbox(self.john['mailbox'])
# send update with new date (and sequence)
- self.send_itip_update(self.room3['mail'], uid, datetime.datetime(2014,8,19, 16,0,0))
+ self.send_itip_update(self.room3['mail'], uid, datetime.datetime(2014, 8, 19, 16, 0, 0))
event = self.check_resource_calendar_event(self.room3['kolabtargetfolder'], uid)
self.assertIsInstance(event, pykolab.xml.Event)
@@ -781,11 +763,12 @@ class TestResourceInvitation(unittest.TestCase):
self.assertEqual(itip_event2['start'].hour, 16)
# resource owner declines the first reservation request
- itip_reply = itip_event1['xml'].to_message_itip(self.jane['mail'],
- method="REPLY",
- participant_status='DECLINED',
- message_text="Request declined",
- subject=_('Booking for %s has been %s') % (self.room3['cn'], participant_status_label('DECLINED'))
+ itip_reply = itip_event1['xml'].to_message_itip(
+ self.jane['mail'],
+ method="REPLY",
+ participant_status='DECLINED',
+ message_text="Request declined",
+ subject=_('Booking for %s has been %s') % (self.room3['cn'], participant_status_label('DECLINED'))
)
smtp = smtplib.SMTP('localhost', 10026)
smtp.sendmail(self.jane['mail'], str(itip_event1['organizer']), str(itip_reply))
@@ -794,36 +777,36 @@ class TestResourceInvitation(unittest.TestCase):
time.sleep(5)
# resource owner accpets the second reservation request
- itip_reply = itip_event2['xml'].to_message_itip(self.jane['mail'],
- method="REPLY",
- participant_status='ACCEPTED',
- message_text="Request accepred",
- subject=_('Booking for %s has been %s') % (self.room3['cn'], participant_status_label('ACCEPTED'))
+ itip_reply = itip_event2['xml'].to_message_itip(
+ self.jane['mail'],
+ method="REPLY",
+ participant_status='ACCEPTED',
+ message_text="Request accepred",
+ subject=_('Booking for %s has been %s') % (self.room3['cn'], participant_status_label('ACCEPTED'))
)
smtp = smtplib.SMTP('localhost', 10026)
smtp.sendmail(self.jane['mail'], str(itip_event2['organizer']), str(itip_reply))
smtp.quit()
# requester (john) now gets the ACCEPTED response
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.room3['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.room3['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_resource_calendar_event(self.room3['kolabtargetfolder'], uid)
self.assertIsInstance(event, pykolab.xml.Event)
self.assertEqual(event.get_attendee_by_email(self.room3['mail']).get_participant_status(True), 'ACCEPTED')
-
def test_016_collection_owner_confirmation(self):
self.purge_mailbox(self.john['mailbox'])
- uid = self.send_itip_invitation(self.viprooms['mail'], datetime.datetime(2014,8,15, 17,0,0))
+ uid = self.send_itip_invitation(self.viprooms['mail'], datetime.datetime(2014, 8, 15, 17, 0, 0))
# resource collection responds with a DELEGATED message
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DELEGATED') }, self.viprooms['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DELEGATED')}, self.viprooms['mail'])
self.assertIsInstance(response, email.message.Message)
# the collection member tentatively accepted the reservation
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('TENTATIVE') })
+ accept = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('TENTATIVE')})
self.assertIsInstance(accept, email.message.Message)
self.assertIn(self.room3['mail'], accept['from'])
@@ -831,15 +814,17 @@ class TestResourceInvitation(unittest.TestCase):
notify = self.check_message_received(_('Booking request for %s requires confirmation') % (self.room3['cn']), mailbox=self.jane['mailbox'])
self.assertIsInstance(notify, email.message.Message)
-
def test_017_reschedule_single_occurrence(self):
self.purge_mailbox(self.john['mailbox'])
+ subject = {'summary': 'test', 'status': participant_status_label('ACCEPTED')}
+ subject = self.itip_reply_subject % (subject)
+
# register a recurring resource invitation
- start = datetime.datetime(2015,2,10, 12,0,0)
+ start = datetime.datetime(2015, 2, 10, 12, 0, 0)
uid = self.send_itip_invitation(self.audi['mail'], start, template=itip_recurring)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(subject)
self.assertIsInstance(accept, email.message.Message)
self.purge_mailbox(self.john['mailbox'])
@@ -849,7 +834,7 @@ class TestResourceInvitation(unittest.TestCase):
exstart = exdate + datetime.timedelta(hours=5)
self.send_itip_update(self.audi['mail'], uid, exstart, instance=exdate)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(subject)
self.assertIsInstance(accept, email.message.Message)
self.assertIn("RECURRENCE-ID;TZID=Europe/London:" + exdate.strftime('%Y%m%dT%H%M%S'), str(accept))
@@ -860,7 +845,7 @@ class TestResourceInvitation(unittest.TestCase):
# send new invitation for now free slot
uid = self.send_itip_invitation(self.audi['mail'], exdate, template=itip_invitation.replace('SUMMARY:test', 'SUMMARY:new'))
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'new', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(subject)
self.assertIsInstance(accept, email.message.Message)
# send rescheduling request to that single instance again: now conflicting
@@ -868,29 +853,31 @@ class TestResourceInvitation(unittest.TestCase):
exstart = exdate + datetime.timedelta(hours=2)
self.send_itip_update(self.audi['mail'], uid, exstart, instance=exdate, sequence=3)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DECLINED') })
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DECLINED')})
self.assertIsInstance(response, email.message.Message)
self.assertIn("RECURRENCE-ID;TZID=Europe/London:", str(response))
-
def test_018_invite_single_occurrence(self):
self.purge_mailbox(self.john['mailbox'])
self.purge_mailbox(self.boxter['kolabtargetfolder'])
- start = datetime.datetime(2015,3,2, 18,30,0)
+ subject = {'summary': 'test', 'status': participant_status_label('ACCEPTED')}
+ subject = self.itip_reply_subject % (subject)
+
+ start = datetime.datetime(2015, 3, 2, 18, 30, 0)
uid = self.send_itip_invitation(self.boxter['mail'], start, instance=start)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(subject)
self.assertIsInstance(accept, email.message.Message)
self.assertIn("RECURRENCE-ID;TZID=Europe/London:" + start.strftime('%Y%m%dT%H%M%S'), str(accept))
self.purge_mailbox(self.john['mailbox'])
# send a second invitation for another instance with the same UID
- nextstart = datetime.datetime(2015,3,9, 18,30,0)
+ nextstart = datetime.datetime(2015, 3, 9, 18, 30, 0)
self.send_itip_invitation(self.boxter['mail'], nextstart, uid=uid, instance=nextstart)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(subject)
self.assertIsInstance(accept, email.message.Message)
self.assertIn("RECURRENCE-ID;TZID=Europe/London:" + nextstart.strftime('%Y%m%dT%H%M%S'), str(accept))
@@ -900,7 +887,7 @@ class TestResourceInvitation(unittest.TestCase):
exstart = start + datetime.timedelta(hours=2)
self.send_itip_update(self.boxter['mail'], uid, exstart, instance=start)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(subject)
self.assertIsInstance(accept, email.message.Message)
self.assertIn("RECURRENCE-ID;TZID=Europe/London:" + start.strftime('%Y%m%dT%H%M%S'), str(accept))
@@ -919,7 +906,7 @@ class TestResourceInvitation(unittest.TestCase):
# send rescheduling request to the 2nd instance
self.send_itip_update(self.boxter['mail'], uid, nextstart + datetime.timedelta(hours=2), sequence=2, instance=nextstart)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(subject)
self.assertIsInstance(accept, email.message.Message)
self.assertIn("RECURRENCE-ID;TZID=Europe/London:" + nextstart.strftime('%Y%m%dT%H%M%S'), str(accept))
@@ -932,15 +919,17 @@ class TestResourceInvitation(unittest.TestCase):
self.assertEqual(two.get_sequence(), 2)
self.assertEqual(two.get_start().hour, 20)
-
def test_019_cancel_single_occurrence(self):
self.purge_mailbox(self.john['mailbox'])
+ subject = {'summary': 'test', 'status': participant_status_label('ACCEPTED')}
+ subject = self.itip_reply_subject % (subject)
+
# register a recurring resource invitation
- start = datetime.datetime(2015,2,12, 14,0,0)
+ start = datetime.datetime(2015, 2, 12, 14, 0, 0)
uid = self.send_itip_invitation(self.passat['mail'], start, template=itip_recurring)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(subject)
self.assertIsInstance(accept, email.message.Message)
exdate = start + datetime.timedelta(days=7)
@@ -958,10 +947,10 @@ class TestResourceInvitation(unittest.TestCase):
self.purge_mailbox(self.john['mailbox'])
# store a single occurrence with recurrence-id
- start = datetime.datetime(2015,3,2, 18,30,0)
+ start = datetime.datetime(2015, 3, 2, 18, 30, 0)
uid = self.send_itip_invitation(self.passat['mail'], start, instance=start)
- accept = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') })
+ accept = self.check_message_received(subject)
self.assertIsInstance(accept, email.message.Message)
self.send_itip_cancel(self.passat['mail'], uid, instance=start)
@@ -969,12 +958,11 @@ class TestResourceInvitation(unittest.TestCase):
time.sleep(5) # wait for IMAP to update
self.assertEqual(self.check_resource_calendar_event(self.passat['kolabtargetfolder'], uid), None)
-
def test_020_owner_confirmation_single_occurrence(self):
self.purge_mailbox(self.john['mailbox'])
self.purge_mailbox(self.jane['mailbox'])
- start = datetime.datetime(2015,4,18, 14,0,0)
+ start = datetime.datetime(2015, 4, 18, 14, 0, 0)
uid = self.send_itip_invitation(self.room3['mail'], start, template=itip_recurring)
notify = self.check_message_received(_('Booking request for %s requires confirmation') % (self.room3['cn']), mailbox=self.jane['mailbox'])
@@ -1004,7 +992,7 @@ class TestResourceInvitation(unittest.TestCase):
self.send_owner_response(itip_event['xml'], 'DECLINED', from_addr=self.jane['mail'])
# requester (john) now gets the DECLINED response
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DECLINED') }, self.room3['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DECLINED')}, self.room3['mail'])
self.assertIsInstance(response, email.message.Message)
self.assertIn("RECURRENCE-ID;TZID=Europe/London:" + exdate.strftime('%Y%m%dT%H%M%S'), str(response))
@@ -1014,4 +1002,3 @@ class TestResourceInvitation(unittest.TestCase):
exception = event.get_instance(exdate)
self.assertEqual(exception.get_attendee_by_email(self.room3['mail']).get_participant_status(True), 'DECLINED')
-
diff --git a/tests/functional/test_wallace/test_006_resource_performance.py b/tests/functional/test_wallace/test_006_resource_performance.py
index ed83611..814a111 100644
--- a/tests/functional/test_wallace/test_006_resource_performance.py
+++ b/tests/functional/test_wallace/test_006_resource_performance.py
@@ -35,7 +35,7 @@ class TestWallacePerformance(unittest.TestCase):
funcs.purge_resources()
self.room1 = funcs.resource_add("confroom", "Room 101")
self.room2 = funcs.resource_add("confroom", "Conference Room B-222")
- self.rooms = funcs.resource_add("collection", "Rooms", [ self.room1['dn'], self.room2['dn'] ])
+ self.rooms = funcs.resource_add("collection", "Rooms", [self.room1['dn'], self.room2['dn']])
time.sleep(1)
synchronize_once()
@@ -74,7 +74,6 @@ class TestWallacePerformance(unittest.TestCase):
saved = module_resources.save_resource_event(dict(xml=event), resource)
i += 1
-
def test_001_save_resource_event(self):
event = Event()
event.set_summary("test")
@@ -86,23 +85,22 @@ class TestWallacePerformance(unittest.TestCase):
saved = module_resources.save_resource_event(dict(xml=event), self.room1)
self.assertTrue(saved)
-
def test_002_read_resource_calendar(self):
self.purge_mailbox(self.room1['kolabtargetfolder'])
event = Event()
event.set_summary("test")
- event.set_start(datetime.datetime(2014,4,1, 12,0,0, tzinfo=pytz.timezone("Europe/London")))
- event.set_end(datetime.datetime(2014,4,1, 14,0,0, tzinfo=pytz.timezone("Europe/London")))
+ event.set_start(datetime.datetime(2014, 4, 1, 12, 0, 0, tzinfo=pytz.timezone("Europe/London")))
+ event.set_end(datetime.datetime(2014, 4, 1, 14, 0, 0, tzinfo=pytz.timezone("Europe/London")))
saved = module_resources.save_resource_event(dict(xml=event), self.room1)
self.assertTrue(saved)
uid = event.get_uid()
itip = dict(
- uid = str(uuid.uuid4()),
- sequence = 0,
- start = datetime.datetime(2014,4,1, 13,0,0, tzinfo=pytz.timezone("Europe/London")),
- end = datetime.datetime(2014,4,1, 14,30,0, tzinfo=pytz.timezone("Europe/London"))
+ uid=str(uuid.uuid4()),
+ sequence=0,
+ start=datetime.datetime(2014, 4, 1, 13, 0, 0, tzinfo=pytz.timezone("Europe/London")),
+ end=datetime.datetime(2014, 4, 1, 14, 30, 0, tzinfo=pytz.timezone("Europe/London"))
)
event.set_uid(itip['uid'])
@@ -110,12 +108,11 @@ class TestWallacePerformance(unittest.TestCase):
event.set_end(itip['end'])
itip['xml'] = event
- res = module_resources.read_resource_calendar(self.room1, [ itip ])
+ res = module_resources.read_resource_calendar(self.room1, [itip])
self.assertEqual(res, 1)
self.assertTrue(self.room1['conflict'])
self.assertIn(uid, self.room1['conflicting_events'])
-
def test_003_read_time(self):
self.purge_mailbox(self.room1['kolabtargetfolder'])
@@ -125,10 +122,10 @@ class TestWallacePerformance(unittest.TestCase):
self.populate_calendar(self.room1, num, date)
itip = dict(
- uid = str(uuid.uuid4()),
- sequence = 0,
- start = date,
- end = date + datetime.timedelta(minutes=90)
+ uid=str(uuid.uuid4()),
+ sequence=0,
+ start=date,
+ end=date + datetime.timedelta(minutes=90)
)
event = Event()
@@ -138,7 +135,7 @@ class TestWallacePerformance(unittest.TestCase):
itip['xml'] = event
start = time.time()
- res = module_resources.read_resource_calendar(self.room1, [ itip ])
+ res = module_resources.read_resource_calendar(self.room1, [itip])
self.assertEqual(res, num)
print "\nREAD TIME:", time.time() - start
diff --git a/tests/functional/test_wallace/test_007_invitationpolicy.py b/tests/functional/test_wallace/test_007_invitationpolicy.py
index f019a91..e11e906 100644
--- a/tests/functional/test_wallace/test_007_invitationpolicy.py
+++ b/tests/functional/test_wallace/test_007_invitationpolicy.py
@@ -221,6 +221,7 @@ Content-Transfer-Encoding: 8bit
--=_c8894dbdb8baeedacae836230e3436fd--
"""
+
class TestWallaceInvitationpolicy(unittest.TestCase):
john = None
@@ -236,7 +237,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
@classmethod
def setup_class(self, *args, **kw):
# set language to default
- pykolab.translate.setUserLanguage(conf.get('kolab','default_locale'))
+ pykolab.translate.setUserLanguage(conf.get('kolab', 'default_locale'))
self.itip_reply_subject = _('"%(summary)s" has been %(status)s')
@@ -251,7 +252,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
'mailbox': 'user/john.doe@example.org',
'kolabcalendarfolder': 'user/john.doe/Calendar@example.org',
'kolabtasksfolder': 'user/john.doe/Tasks@example.org',
- 'kolabinvitationpolicy': ['ACT_UPDATE_AND_NOTIFY','ACT_MANUAL']
+ 'kolabinvitationpolicy': ['ACT_UPDATE_AND_NOTIFY', 'ACT_MANUAL']
}
self.jane = {
@@ -263,7 +264,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
'kolabcalendarfolder': 'user/jane.manager/Calendar@example.org',
'kolabtasksfolder': 'user/jane.manager/Tasks@example.org',
'kolabconfidentialcalendar': 'user/jane.manager/Calendar/Confidential@example.org',
- 'kolabinvitationpolicy': ['ACT_ACCEPT_IF_NO_CONFLICT','ACT_REJECT_IF_CONFLICT','TASK_ACCEPT','TASK_UPDATE_AND_NOTIFY','ACT_UPDATE']
+ 'kolabinvitationpolicy': ['ACT_ACCEPT_IF_NO_CONFLICT', 'ACT_REJECT_IF_CONFLICT', 'TASK_ACCEPT', 'TASK_UPDATE_AND_NOTIFY', 'ACT_UPDATE']
}
self.jack = {
@@ -274,7 +275,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
'mailbox': 'user/jack.tentative@example.org',
'kolabcalendarfolder': 'user/jack.tentative/Calendar@example.org',
'kolabtasksfolder': 'user/jack.tentative/Tasks@example.org',
- 'kolabinvitationpolicy': ['ACT_TENTATIVE_IF_NO_CONFLICT','ALL_SAVE_TO_FOLDER','ACT_UPDATE']
+ 'kolabinvitationpolicy': ['ACT_TENTATIVE_IF_NO_CONFLICT', 'ALL_SAVE_TO_FOLDER', 'ACT_UPDATE']
}
self.mark = {
@@ -285,7 +286,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
'mailbox': 'user/mark.german@example.org',
'kolabcalendarfolder': 'user/mark.german/Calendar@example.org',
'kolabtasksfolder': 'user/mark.german/Tasks@example.org',
- 'kolabinvitationpolicy': ['ACT_ACCEPT','ACT_UPDATE_AND_NOTIFY']
+ 'kolabinvitationpolicy': ['ACT_ACCEPT', 'ACT_UPDATE_AND_NOTIFY']
}
self.lucy = {
@@ -296,7 +297,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
'mailbox': 'user/lucy.meyer@example.org',
'kolabcalendarfolder': 'user/lucy.meyer/Calendar@example.org',
'kolabtasksfolder': 'user/lucy.meyer/Tasks@example.org',
- 'kolabinvitationpolicy': ['ALL_SAVE_AND_FORWARD','ACT_CANCEL_DELETE_AND_NOTIFY','ACT_UPDATE_AND_NOTIFY']
+ 'kolabinvitationpolicy': ['ALL_SAVE_AND_FORWARD', 'ACT_CANCEL_DELETE_AND_NOTIFY', 'ACT_UPDATE_AND_NOTIFY']
}
self.bill = {
@@ -307,7 +308,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
'mailbox': 'user/bill.mayor@example.org',
'kolabcalendarfolder': 'user/bill.mayor/Calendar@example.org',
'kolabtasksfolder': 'user/bill.mayor/Tasks@example.org',
- 'kolabinvitationpolicy': ['ALL_SAVE_TO_FOLDER:lucy.meyer@example.org','ALL_REJECT']
+ 'kolabinvitationpolicy': ['ALL_SAVE_TO_FOLDER:lucy.meyer@example.org', 'ALL_REJECT']
}
self.external = {
@@ -330,7 +331,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
# create confidential calendar folder for jane
imap = IMAP()
- imap.connect(domain='example.org') # sets self.domain
+ imap.connect(domain='example.org') # sets self.domain
imap.user_mailbox_create_additional_folders(self.jane['mail'], {
'Calendar/Confidential': {
'annotations': {
@@ -343,7 +344,6 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
imap.set_acl(imap.folder_quote(self.jane['kolabcalendarfolder']), self.mark['mail'], "lrswipkxtecda")
imap.disconnect()
-
def send_message(self, itip_payload, to_addr, from_addr=None, method="REQUEST"):
if from_addr is None:
from_addr = self.john['mail']
@@ -672,12 +672,11 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
imap.imap.m.expunge()
imap.disconnect()
-
def test_001_invite_accept_udate(self):
- start = datetime.datetime(2014,8,13, 10,0,0)
+ start = datetime.datetime(2014, 8, 13, 10, 0, 0)
uid = self.send_itip_invitation(self.jane['mail'], start)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid)
@@ -693,38 +692,35 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(event.get_summary(), "test updated")
self.assertEqual(event.get_attendee(self.jane['mail']).get_participant_status(), kolabformat.PartAccepted)
-
# @depends on test_001_invite_user
def test_002_invite_conflict_reject(self):
- uid = self.send_itip_invitation(self.jane['mail'], datetime.datetime(2014,8,13, 11,0,0), summary="test2")
+ uid = self.send_itip_invitation(self.jane['mail'], datetime.datetime(2014, 8, 13, 11, 0, 0), summary="test2")
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test2', 'status':participant_status_label('DECLINED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test2', 'status': participant_status_label('DECLINED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid)
self.assertIsInstance(event, pykolab.xml.Event)
self.assertEqual(event.get_summary(), "test2")
-
def test_003_invite_accept_tentative(self):
self.purge_mailbox(self.john['mailbox'])
- uid = self.send_itip_invitation(self.jack['mail'], datetime.datetime(2014,7,24, 8,0,0))
+ uid = self.send_itip_invitation(self.jack['mail'], datetime.datetime(2014, 7, 24, 8, 0, 0))
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('TENTATIVE') }, self.jack['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('TENTATIVE')}, self.jack['mail'])
self.assertIsInstance(response, email.message.Message)
-
def test_004_copy_to_calendar(self):
self.purge_mailbox(self.john['mailbox'])
- self.send_itip_invitation(self.jack['mail'], datetime.datetime(2014,7,29, 8,0,0))
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('TENTATIVE') }, self.jack['mail'])
+ self.send_itip_invitation(self.jack['mail'], datetime.datetime(2014, 7, 29, 8, 0, 0))
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('TENTATIVE')}, self.jack['mail'])
self.assertIsInstance(response, email.message.Message)
# send conflicting request to jack
- uid = self.send_itip_invitation(self.jack['mail'], datetime.datetime(2014,7,29, 10,0,0), summary="test2")
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test2', 'status':participant_status_label('DECLINED') }, self.jack['mail'])
+ uid = self.send_itip_invitation(self.jack['mail'], datetime.datetime(2014, 7, 29, 10, 0, 0), summary="test2")
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test2', 'status': participant_status_label('DECLINED')}, self.jack['mail'])
self.assertEqual(response, None, "No reply expected")
event = self.check_user_calendar_event(self.jack['kolabcalendarfolder'], uid)
@@ -732,10 +728,9 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(event.get_summary(), "test2")
self.assertEqual(event.get_attendee(self.jack['mail']).get_participant_status(), kolabformat.PartNeedsAction)
-
def test_004_copy_to_calendar_and_forward(self):
- uid = self.send_itip_invitation(self.lucy['mail'], datetime.datetime(2015,2,11, 14,0,0), summary="test forward")
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test forward', 'status':participant_status_label('ACCEPTED') }, self.lucy['mail'], self.lucy['mailbox'])
+ uid = self.send_itip_invitation(self.lucy['mail'], datetime.datetime(2015, 2, 11, 14, 0, 0), summary="test forward")
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test forward', 'status': participant_status_label('ACCEPTED')}, self.lucy['mail'], self.lucy['mailbox'])
self.assertEqual(response, None, "No reply expected")
event = self.check_user_calendar_event(self.lucy['kolabcalendarfolder'], uid)
@@ -748,18 +743,17 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertIsInstance(message, email.message.Message)
itips = events_from_message(message)
- self.assertEqual(len(itips), 1);
- self.assertEqual(itips[0]['method'], 'REQUEST');
- self.assertEqual(itips[0]['uid'], uid);
-
+ self.assertEqual(len(itips), 1)
+ self.assertEqual(itips[0]['method'], 'REQUEST')
+ self.assertEqual(itips[0]['uid'], uid)
def test_005_invite_rescheduling_accept(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2014,8,14, 9,0,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2014, 8, 14, 9, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.send_itip_invitation(self.jane['mail'], start)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid)
@@ -769,10 +763,10 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.purge_mailbox(self.john['mailbox'])
# send update with new date and incremented sequence
- new_start = pytz.timezone("Europe/Berlin").localize(datetime.datetime(2014,8,15, 15,0,0))
+ new_start = pytz.timezone("Europe/Berlin").localize(datetime.datetime(2014, 8, 15, 15, 0, 0))
self.send_itip_update(self.jane['mail'], uid, new_start, summary="test", sequence=1)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid)
@@ -780,23 +774,22 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(event.get_start(), new_start)
self.assertEqual(event.get_sequence(), 1)
-
def test_005_invite_rescheduling_reject(self):
self.purge_mailbox(self.john['mailbox'])
self.purge_mailbox(self.jack['kolabcalendarfolder'])
- start = datetime.datetime(2014,8,9, 17,0,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2014, 8, 9, 17, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.send_itip_invitation(self.jack['mail'], start)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('TENTATIVE') }, self.jack['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('TENTATIVE')}, self.jack['mail'])
self.assertIsInstance(response, email.message.Message)
# send update with new but conflicting date and incremented sequence
- self.create_calendar_event(datetime.datetime(2014,8,10, 10,30,0, tzinfo=pytz.timezone("Europe/Berlin")), user=self.jack)
- new_start = pytz.timezone("Europe/Berlin").localize(datetime.datetime(2014,8,10, 9,30,0))
+ self.create_calendar_event(datetime.datetime(2014, 8, 10, 10, 30, 0, tzinfo=pytz.timezone("Europe/Berlin")), user=self.jack)
+ new_start = pytz.timezone("Europe/Berlin").localize(datetime.datetime(2014, 8, 10, 9, 30, 0))
self.send_itip_update(self.jack['mail'], uid, new_start, summary="test (updated)", sequence=1)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DECLINED') }, self.jack['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DECLINED')}, self.jack['mail'])
self.assertEqual(response, None)
# verify re-scheduled copy in jack's calendar with NEEDS-ACTION
@@ -809,11 +802,10 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertTrue(attendee.get_rsvp())
self.assertEqual(attendee.get_participant_status(), kolabformat.PartNeedsAction)
-
def test_006_invitation_reply(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2014,8,18, 14,30,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2014, 8, 18, 14, 30, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.create_calendar_event(start, user=self.john)
event = self.check_user_calendar_event(self.john['kolabcalendarfolder'], uid)
@@ -836,11 +828,10 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(len(attachments), 1)
self.assertEqual(event.get_attachment_data(0), 'This is a text attachment')
-
def test_006_invitation_reply_delegated(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2014,8,28, 14,30,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2014, 8, 28, 14, 30, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.create_calendar_event(start, user=self.john)
event = self.check_user_calendar_event(self.john['kolabcalendarfolder'], uid)
@@ -866,13 +857,12 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(len(delegatee.get_delegated_from()), 1)
self.assertEqual(delegatee.get_delegated_from(True)[0], self.jane['mail'])
-
def test_007_invitation_cancel(self):
self.purge_mailbox(self.john['mailbox'])
uid = self.send_itip_invitation(self.jane['mail'], summary="cancelled")
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'cancelled', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'cancelled', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
self.send_itip_cancel(self.jane['mail'], uid, summary="cancelled")
@@ -884,7 +874,6 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(event.get_status(True), 'CANCELLED')
self.assertTrue(event.get_transparency())
-
def test_007_invitation_cancel_and_delete(self):
self.purge_mailbox(self.john['mailbox'])
@@ -900,11 +889,10 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
# verify event was removed from the user's calendar
self.assertEqual(self.check_user_calendar_event(self.lucy['kolabcalendarfolder'], uid), None)
-
def test_008_inivtation_reply_notify(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2014,8,12, 16,0,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2014, 8, 12, 16, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.create_calendar_event(start, user=self.john, attendees=[self.jane, self.mark, self.jack])
# send a reply from jane to john
@@ -921,7 +909,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
notification = self.check_message_received(_('"%s" has been updated') % ('test'), self.john['mail'])
self.assertIsInstance(notification, email.message.Message)
- notification_text = str(notification.get_payload());
+ notification_text = str(notification.get_payload())
self.assertIn(self.jane['mail'], notification_text)
self.assertIn(_("PENDING"), notification_text)
@@ -934,14 +922,13 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
notification = self.check_message_received(_('"%s" has been updated') % ('test'), self.john['mail'])
self.assertIsInstance(notification, email.message.Message)
- notification_text = str(notification.get_payload());
+ notification_text = str(notification.get_payload())
self.assertNotIn(_("PENDING"), notification_text)
-
def test_008_notify_translated(self):
self.purge_mailbox(self.mark['mailbox'])
- start = datetime.datetime(2014,8,12, 16,0,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2014, 8, 12, 16, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.create_calendar_event(start, user=self.mark, attendees=[self.jane])
# send a reply from jane to mark
@@ -952,18 +939,17 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
notification = self.check_message_received(_('"%s" has been updated') % ('test'), self.mark['mail'], self.mark['mailbox'])
self.assertIsInstance(notification, email.message.Message)
- notification_text = str(notification.get_payload());
+ notification_text = str(notification.get_payload())
self.assertIn(self.jane['mail'], notification_text)
self.assertIn(participant_status_label("ACCEPTED")+":", notification_text)
# reset localization
- pykolab.translate.setUserLanguage(conf.get('kolab','default_locale'))
-
+ pykolab.translate.setUserLanguage(conf.get('kolab', 'default_locale'))
def test_009_outdated_reply(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2014,9,2, 11,0,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2014, 9, 2, 11, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.create_calendar_event(start, user=self.john, sequence=2)
# send a reply from jane to john
@@ -976,11 +962,10 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(event.get_sequence(), 2)
self.assertEqual(event.get_attendee(self.jane['mail']).get_participant_status(), kolabformat.PartNeedsAction)
-
def test_010_partstat_update_propagation(self):
# ATTENTION: this test requires wallace.invitationpolicy_autoupdate_other_attendees_on_reply to be enabled in config
- start = datetime.datetime(2014,8,21, 13,0,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2014, 8, 21, 13, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.create_calendar_event(start, user=self.john, attendees=[self.jane, self.jack, self.external])
event = self.check_user_calendar_event(self.john['kolabcalendarfolder'], uid)
@@ -1011,7 +996,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(jacks.get_attendee(self.jack['mail']).get_participant_status(), kolabformat.PartTentative)
# PART 2: create conflicting event in jack's calendar
- new_start = datetime.datetime(2014,8,21, 6,0,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ new_start = datetime.datetime(2014, 8, 21, 6, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
self.create_calendar_event(new_start, user=self.jack, attendees=[], summary="blocker")
# re-schedule initial event to new date
@@ -1033,12 +1018,11 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(jacks.get_attendee(self.jane['mail']).get_participant_status(), kolabformat.PartAccepted)
self.assertEqual(jacks.get_attendee(self.jack['mail']).get_participant_status(), kolabformat.PartNeedsAction)
-
def test_011_manual_schedule_auto_update(self):
self.purge_mailbox(self.john['mailbox'])
# create an event in john's calendar as it was manually accepted
- start = datetime.datetime(2014,9,2, 11,0,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2014, 9, 2, 11, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.create_calendar_event(start, user=self.jane, sequence=1, folder=self.john['kolabcalendarfolder'])
# send update with the same sequence: no re-scheduling
@@ -1060,9 +1044,8 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
notification = self.check_message_received(_('"%s" has been updated') % ('old test'), self.jane['mail'], mailbox=self.john['mailbox'])
self.assertEqual(notification, None)
-
def test_012_confidential_invitation(self):
- start = datetime.datetime(2014,9,21, 9,30,0)
+ start = datetime.datetime(2014, 9, 21, 9, 30, 0)
uid = self.send_itip_invitation(self.jane['mail'], start, summary='confidential', template=itip_invitation.replace("DESCRIPTION:test", "CLASS:CONFIDENTIAL"))
# check event being stored in the folder annotared with event.confidential
@@ -1070,10 +1053,9 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertIsInstance(event, pykolab.xml.Event)
self.assertEqual(event.get_summary(), "confidential")
-
def test_013_update_shared_folder(self):
# create an event organized by Mark (a delegate of Jane) into Jane's calendar
- start = datetime.datetime(2015,3,10, 9,30,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ start = datetime.datetime(2015, 3, 10, 9, 30, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.create_calendar_event(start, user=self.mark, attendees=[self.jane, self.john], folder=self.jane['kolabcalendarfolder'])
event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid)
@@ -1090,28 +1072,27 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
def test_014_per_sender_policy(self):
# send invitation from john => REJECT
- start = datetime.datetime(2015,2,28, 14,0,0)
+ start = datetime.datetime(2015, 2, 28, 14, 0, 0)
uid = self.send_itip_invitation(self.bill['mail'], start)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('DECLINED') }, self.bill['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('DECLINED')}, self.bill['mail'])
self.assertIsInstance(response, email.message.Message)
# send invitation from lucy => SAVE
- start = datetime.datetime(2015,3,11, 10,0,0)
+ start = datetime.datetime(2015, 3, 11, 10, 0, 0)
templ = itip_invitation.replace("Doe, John", self.lucy['displayname'])
uid = self.send_itip_invitation(self.bill['mail'], start, template=templ, from_addr=self.lucy['mail'])
event = self.check_user_calendar_event(self.bill['kolabcalendarfolder'], uid)
self.assertIsInstance(event, pykolab.xml.Event)
-
def test_015_update_single_occurrence(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2015,4,2, 14,0,0)
+ start = datetime.datetime(2015, 4, 2, 14, 0, 0)
uid = self.send_itip_invitation(self.jane['mail'], start, template=itip_recurring)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid)
@@ -1131,14 +1112,13 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(exception.get_summary(), "test exception")
self.assertEqual(exception.get_attendee(self.jane['mail']).get_participant_status(), kolabformat.PartAccepted)
-
def test_015_reschedule_single_occurrence(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2015,4,10, 9,0,0)
+ start = datetime.datetime(2015, 4, 10, 9, 0, 0)
uid = self.send_itip_invitation(self.jane['mail'], start, template=itip_recurring)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
# send update to a single instance with the same sequence: no re-scheduling
@@ -1146,7 +1126,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
exstart = exdate + datetime.timedelta(hours=5)
self.send_itip_update(self.jane['mail'], uid, exstart, summary="test resceduled", sequence=1, partstat='NEEDS-ACTION', instance=exdate)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test resceduled', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test resceduled', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
time.sleep(10)
@@ -1158,7 +1138,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
exstart = exdate + datetime.timedelta(hours=6)
self.send_itip_update(self.jane['mail'], uid, exstart, summary="test new", sequence=2, partstat='NEEDS-ACTION', instance=exdate)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'test new', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'test new', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
# check for updated excaption
@@ -1171,11 +1151,10 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertIsInstance(exception, pykolab.xml.Event)
self.assertEqual(exception.get_start().strftime('%Y%m%dT%H%M%S'), exstart.strftime('%Y%m%dT%H%M%S'))
-
def test_016_reply_single_occurrence(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2015,3,7, 10,0,0, tzinfo=pytz.timezone("Europe/Zurich"))
+ start = datetime.datetime(2015, 3, 7, 10, 0, 0, tzinfo=pytz.timezone("Europe/Zurich"))
uid = self.create_calendar_event(start, attendees=[self.jane, self.mark], recurring=True)
event = self.check_user_calendar_event(self.john['kolabcalendarfolder'], uid)
@@ -1220,10 +1199,10 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
def test_017_cancel_single_occurrence(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2015,3,20, 19,0,0, tzinfo=pytz.timezone("Europe/Zurich"))
+ start = datetime.datetime(2015, 3, 20, 19, 0, 0, tzinfo=pytz.timezone("Europe/Zurich"))
uid = self.send_itip_invitation(self.jane['mail'], summary="recurring", start=start, template=itip_recurring)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'recurring', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'recurring', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid)
@@ -1244,13 +1223,13 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
# send a new invitation for the cancelled slot
uid = self.send_itip_invitation(self.jane['mail'], summary="new booking", start=exdate)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'new booking', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'new booking', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
def test_017_cancel_delete_single_occurrence(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2015,3,24, 13,0,0, tzinfo=pytz.timezone("Europe/Zurich"))
+ start = datetime.datetime(2015, 3, 24, 13, 0, 0, tzinfo=pytz.timezone("Europe/Zurich"))
uid = self.send_itip_invitation(self.lucy['mail'], summary="recurring cancel-delete", start=start, template=itip_recurring)
event = self.check_user_calendar_event(self.lucy['kolabcalendarfolder'], uid)
@@ -1281,11 +1260,11 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
def test_017_cancel_thisandfuture(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2015,5,4, 6,30,0)
+ start = datetime.datetime(2015, 5, 4, 6, 30, 0)
uid = self.send_itip_invitation(self.mark['mail'], summary="recurring", start=start, template=itip_recurring)
pykolab.translate.setUserLanguage(self.mark['preferredlanguage'])
- response = self.check_message_received(_('"%(summary)s" has been %(status)s') % { 'summary':'recurring', 'status':participant_status_label('ACCEPTED') }, self.mark['mail'])
+ response = self.check_message_received(_('"%(summary)s" has been %(status)s') % {'summary': 'recurring', 'status': participant_status_label('ACCEPTED')}, self.mark['mail'])
self.assertIsInstance(response, email.message.Message)
pykolab.translate.setUserLanguage(conf.get('kolab','default_locale'))
@@ -1304,14 +1283,13 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertIsInstance(rrule['until'], datetime.datetime)
self.assertEqual(rrule['until'].strftime('%Y%m%d'), (exdate - datetime.timedelta(days=1)).strftime('%Y%m%d'))
-
def test_018_invite_individual_occurrences(self):
self.purge_mailbox(self.john['mailbox'])
- start = datetime.datetime(2015,1,30, 17,0,0, tzinfo=pytz.timezone("Europe/Zurich"))
+ start = datetime.datetime(2015, 1, 30, 17, 0, 0, tzinfo=pytz.timezone("Europe/Zurich"))
uid = self.send_itip_invitation(self.jane['mail'], summary="single", start=start, instance=start)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'single', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'single', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
self.assertIn("RECURRENCE-ID", str(response))
@@ -1320,10 +1298,10 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertIsInstance(event.get_recurrence_id(), datetime.datetime)
# send another invitation with the same UID for different RECURRENCE-ID
- newstart = datetime.datetime(2015,2,6, 17,0,0, tzinfo=pytz.timezone("Europe/Zurich"))
+ newstart = datetime.datetime(2015, 2, 6, 17, 0, 0, tzinfo=pytz.timezone("Europe/Zurich"))
self.send_itip_invitation(self.jane['mail'], summary="single #2", uid=uid, start=newstart, instance=newstart)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'single #2', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'single #2', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
self.assertIn("RECURRENCE-ID", str(response))
@@ -1350,12 +1328,11 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
exception = event.get_instance(newstart)
self.assertEqual(exception.get_summary(), "updated #2")
-
def test_020_task_assignment_accept(self):
- start = datetime.datetime(2014,9,10, 19,0,0)
+ start = datetime.datetime(2014, 9, 10, 19, 0, 0)
uid = self.send_itip_invitation(self.jane['mail'], start, summary='work', template=itip_todo)
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'work', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'work', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertIsInstance(response, email.message.Message)
todo = self.check_user_imap_object(self.jane['kolabtasksfolder'], uid, 'task')
@@ -1365,7 +1342,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
# send update with the same sequence: no re-scheduling
self.send_itip_update(self.jane['mail'], uid, start, summary='work updated', template=itip_todo, sequence=0, partstat='ACCEPTED')
- response = self.check_message_received(self.itip_reply_subject % { 'summary':'work updated', 'status':participant_status_label('ACCEPTED') }, self.jane['mail'])
+ response = self.check_message_received(self.itip_reply_subject % {'summary': 'work updated', 'status': participant_status_label('ACCEPTED')}, self.jane['mail'])
self.assertEqual(response, None)
time.sleep(10)
@@ -1374,11 +1351,10 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(todo.get_summary(), "work updated")
self.assertEqual(todo.get_attendee(self.jane['mail']).get_participant_status(), kolabformat.PartAccepted)
-
def test_021_task_assignment_reply(self):
self.purge_mailbox(self.john['mailbox'])
- due = datetime.datetime(2014,9,12, 14,0,0, tzinfo=pytz.timezone("Europe/Berlin"))
+ due = datetime.datetime(2014, 9, 12, 14, 0, 0, tzinfo=pytz.timezone("Europe/Berlin"))
uid = self.create_task_assignment(due, user=self.john)
todo = self.check_user_imap_object(self.john['kolabtasksfolder'], uid, 'task')
@@ -1401,10 +1377,9 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
notification = self.check_message_received(_('"%s" has been updated') % ('test'), self.john['mail'])
self.assertIsInstance(notification, email.message.Message)
- notification_text = str(notification.get_payload());
+ notification_text = str(notification.get_payload())
self.assertIn(participant_status_label(partstat), notification_text)
-
def test_022_task_cancellation(self):
uid = self.send_itip_invitation(self.jane['mail'], summary='more work', template=itip_todo)
@@ -1420,4 +1395,3 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
# this should trigger a notification message
notification = self.check_message_received(_('"%s" has been cancelled') % ('more work'), self.john['mail'], mailbox=self.jane['mailbox'])
self.assertIsInstance(notification, email.message.Message)
-
diff --git a/tests/functional/test_wap_client/__init__.py b/tests/functional/test_wap_client/__init__.py
index d7bf27f..d6cdb57 100644
--- a/tests/functional/test_wap_client/__init__.py
+++ b/tests/functional/test_wap_client/__init__.py
@@ -1,5 +1,6 @@
import pykolab
+
def setup_package():
conf = pykolab.getConf()
conf.finalize_conf(fatal=False)
diff --git a/tests/functional/test_wap_client/test_001_connect.py b/tests/functional/test_wap_client/test_001_connect.py
index aa0c069..783d996 100644
--- a/tests/functional/test_wap_client/test_001_connect.py
+++ b/tests/functional/test_wap_client/test_001_connect.py
@@ -3,6 +3,7 @@ import unittest
import pykolab
from pykolab import wap_client
+
class TestConnect(unittest.TestCase):
@classmethod
def setup_class(self, *args, **kw):
@@ -18,23 +19,23 @@ class TestConnect(unittest.TestCase):
def test_002_response_ok(self):
result = wap_client.request_raw('POST', 'domains.list')
- self.assertTrue(result.has_key('status'))
- self.assertTrue(result.has_key('result'))
+ self.assertTrue('status' in result)
+ self.assertTrue('result' in result)
self.assertEqual(result['status'], "OK")
def test_003_response_fail(self):
result = wap_client.request_raw('POST', 'service.method')
- self.assertTrue(result.has_key('status'))
- self.assertTrue(result.has_key('reason'))
- self.assertTrue(result.has_key('code'))
+ self.assertTrue('status' in result)
+ self.assertTrue('reason' in result)
+ self.assertTrue('code' in result)
self.assertEqual(result['status'], "ERROR")
self.assertEqual(result['reason'], "Unknown service")
self.assertEqual(result['code'], 400)
def test_004_domains_list(self):
result = wap_client.domains_list()
- self.assertTrue(result.has_key('count'))
- self.assertTrue(result.has_key('list'))
+ self.assertTrue('count' in result)
+ self.assertTrue('list' in result)
self.assertEqual(result['count'], len(result['list']))
def test_005_get_domain(self):
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 96c3de1..771e700 100644
--- a/tests/functional/test_wap_client/test_002_user_add.py
+++ b/tests/functional/test_wap_client/test_002_user_add.py
@@ -8,6 +8,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestUserAdd(unittest.TestCase):
@classmethod
@@ -31,7 +32,6 @@ class TestUserAdd(unittest.TestCase):
purge_users()
def test_001_inbox_created(self):
-
time.sleep(2)
imap = IMAP()
imap.connect()
@@ -67,14 +67,12 @@ class TestUserAdd(unittest.TestCase):
metadata = imap.get_metadata(folder)
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():
+ if folder_name in ac_folders:
+ if 'annotations' in ac_folders[folder_name]:
+ for _annotation in ac_folders[folder_name]['annotations']:
if _annotation.startswith('/private/'):
continue
_annotation_value = ac_folders[folder_name]['annotations'][_annotation]
- self.assertTrue(metadata[metadata.keys().pop()].has_key(_annotation))
+ self.assertTrue(_annotation in metadata[metadata.keys().pop()])
self.assertEqual(_annotation_value, metadata[metadata.keys().pop()][_annotation])
-
-
diff --git a/tests/functional/test_wap_client/test_003_user_add_fr_FR.py b/tests/functional/test_wap_client/test_003_user_add_fr_FR.py
index b9ef510..72cf84b 100644
--- a/tests/functional/test_wap_client/test_003_user_add_fr_FR.py
+++ b/tests/functional/test_wap_client/test_003_user_add_fr_FR.py
@@ -10,6 +10,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestUserAddFrFR(unittest.TestCase):
@classmethod
def setup_class(self, *args, **kw):
@@ -32,7 +33,6 @@ class TestUserAddFrFR(unittest.TestCase):
purge_users()
def test_001_inbox_created(self):
-
time.sleep(2)
imap = IMAP()
imap.connect()
@@ -54,5 +54,3 @@ class TestUserAddFrFR(unittest.TestCase):
self.assertEqual(result['mail'], 'etienne-nicolas.mehul@example.org')
self.assertEqual(sorted(result['alias']), ['e.mehul@example.org', 'mehul@example.org'])
-
-
diff --git a/tests/functional/test_wap_client/test_004_user_add_es_ES.py b/tests/functional/test_wap_client/test_004_user_add_es_ES.py
index a681a2d..7fc5d83 100644
--- a/tests/functional/test_wap_client/test_004_user_add_es_ES.py
+++ b/tests/functional/test_wap_client/test_004_user_add_es_ES.py
@@ -10,6 +10,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestUserAddEsES(unittest.TestCase):
@classmethod
@@ -33,7 +34,6 @@ class TestUserAddEsES(unittest.TestCase):
purge_users()
def test_001_inbox_created(self):
-
time.sleep(2)
imap = IMAP()
imap.connect()
@@ -54,5 +54,3 @@ class TestUserAddEsES(unittest.TestCase):
self.assertEqual(result['mail'], 'alvaro.fuentes@example.org')
self.assertEqual(sorted(result['alias']), ['a.fuentes@example.org', 'fuentes@example.org'])
-
-
diff --git a/tests/functional/test_wap_client/test_005_user_add_de_CH.py b/tests/functional/test_wap_client/test_005_user_add_de_CH.py
index dd38383..c2d22c6 100644
--- a/tests/functional/test_wap_client/test_005_user_add_de_CH.py
+++ b/tests/functional/test_wap_client/test_005_user_add_de_CH.py
@@ -10,6 +10,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestUserAddDeCH(unittest.TestCase):
@classmethod
def setup_class(self, *args, **kw):
@@ -53,5 +54,3 @@ class TestUserAddDeCH(unittest.TestCase):
self.assertEqual(result['mail'], 'thomas.bruederli@example.org')
self.assertEqual(sorted(result['alias']), ['bruederli@example.org', 't.bruederli@example.org'])
-
-
diff --git a/tests/functional/test_wap_client/test_006_form_value_select_options.py b/tests/functional/test_wap_client/test_006_form_value_select_options.py
index 92b4992..0f2bbdd 100644
--- a/tests/functional/test_wap_client/test_006_form_value_select_options.py
+++ b/tests/functional/test_wap_client/test_006_form_value_select_options.py
@@ -6,6 +6,7 @@ from pykolab import wap_client
conf = pykolab.getConf()
+
class TestFormValueListOptions(unittest.TestCase):
def test_001_list_options_user_preferredlanguage(self):
@@ -24,8 +25,7 @@ class TestFormValueListOptions(unittest.TestCase):
'preferredlanguage'
)
- self.assertTrue(attribute_values['preferredlanguage'].has_key('default'))
- self.assertTrue(attribute_values['preferredlanguage'].has_key('list'))
+ self.assertTrue('default' in attribute_values['preferredlanguage'])
+ self.assertTrue('list' in attribute_values['preferredlanguage'])
self.assertTrue(len(attribute_values['preferredlanguage']['list']) > 1)
self.assertTrue(attribute_values['preferredlanguage']['default'] in attribute_values['preferredlanguage']['list'])
-
diff --git a/tests/functional/test_wap_client/test_007_policy_uid.py b/tests/functional/test_wap_client/test_007_policy_uid.py
index 534ebda..a10eeb9 100644
--- a/tests/functional/test_wap_client/test_007_policy_uid.py
+++ b/tests/functional/test_wap_client/test_007_policy_uid.py
@@ -9,6 +9,7 @@ from pykolab.imap import IMAP
conf = pykolab.getConf()
+
class TestPolicyUid(unittest.TestCase):
def remove_option(self, section, option):
@@ -172,5 +173,3 @@ class TestPolicyUid(unittest.TestCase):
from tests.functional.purge_users import purge_users
purge_users()
-
-
diff --git a/tests/functional/test_wap_client/test_008_resource_add.py b/tests/functional/test_wap_client/test_008_resource_add.py
index 5647d0c..f4b4c20 100644
--- a/tests/functional/test_wap_client/test_008_resource_add.py
+++ b/tests/functional/test_wap_client/test_008_resource_add.py
@@ -10,6 +10,7 @@ import tests.functional.resource_func as funcs
conf = pykolab.getConf()
+
class TestResourceAdd(unittest.TestCase):
@classmethod
@@ -29,7 +30,7 @@ class TestResourceAdd(unittest.TestCase):
self.audi = funcs.resource_add("car", "Audi A4")
self.passat = funcs.resource_add("car", "VW Passat")
self.boxter = funcs.resource_add("car", "Porsche Boxter S")
- self.cars = funcs.resource_add("collection", "Company Cars", [ self.audi['dn'], self.passat['dn'], self.boxter['dn'] ])
+ self.cars = funcs.resource_add("collection", "Company Cars", [self.audi['dn'], self.passat['dn'], self.boxter['dn']])
from tests.functional.synchronize import synchronize_once
synchronize_once()
diff --git a/tests/functional/user_add.py b/tests/functional/user_add.py
index b1b37f1..35e2b6b 100644
--- a/tests/functional/user_add.py
+++ b/tests/functional/user_add.py
@@ -4,17 +4,12 @@ from pykolab import wap_client
conf = pykolab.getConf()
-def user_add(givenname, sn, preferredlanguage='en_US', **kw):
- if givenname == None:
- raise Exception
-
- if givenname == '':
- raise Exception
- if sn == None:
+def user_add(givenname, sn, preferredlanguage='en_US', **kw):
+ if givenname is None or givenname == '':
raise Exception
- if sn == '':
+ if sn is None or sn == '':
raise Exception
user_details = {
@@ -51,7 +46,7 @@ def user_add(givenname, sn, preferredlanguage='en_US', **kw):
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 or user_details.has_key(attribute):
+ if 'optional' not in attr_details or attr_details['optional'] is False or attribute in user_details:
params[attribute] = user_details[attribute]
elif isinstance(attr_details, list):
params[attribute] = user_details[attribute]
@@ -59,7 +54,6 @@ def user_add(givenname, sn, preferredlanguage='en_US', **kw):
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()]
+ fvg_params['attributes'] = [attr for attr in user_type_info['auto_form_fields'].keys() if attr not in params]
result = wap_client.user_add(params)
-
diff --git a/tests/unit/test-000-imports.py b/tests/unit/test-000-imports.py
index 17e1c57..9c65e6d 100644
--- a/tests/unit/test-000-imports.py
+++ b/tests/unit/test-000-imports.py
@@ -1,5 +1,6 @@
import unittest
+
class TestImports(unittest.TestCase):
def test_pykolab(self):
import pykolab
diff --git a/tests/unit/test-001-contact_reference.py b/tests/unit/test-001-contact_reference.py
index 7c8f128..a566f9e 100644
--- a/tests/unit/test-001-contact_reference.py
+++ b/tests/unit/test-001-contact_reference.py
@@ -3,6 +3,7 @@ import unittest
from pykolab.xml import ContactReference
+
class TestEventXML(unittest.TestCase):
contact_reference = ContactReference("jane@doe.org")
@@ -13,7 +14,7 @@ class TestEventXML(unittest.TestCase):
if (type(_value)) == _type:
return True
else:
- raise AssertionError, "%s != %s" % (type(_value), _type)
+ raise AssertionError("%s != %s" % (type(_value), _type))
def test_001_minimal(self):
self.assertIsInstance(self.contact_reference.__str__(), str)
diff --git a/tests/unit/test-002-attendee.py b/tests/unit/test-002-attendee.py
index ccde3ac..c90c48e 100644
--- a/tests/unit/test-002-attendee.py
+++ b/tests/unit/test-002-attendee.py
@@ -5,6 +5,7 @@ import kolabformat
from pykolab.xml import Attendee
from pykolab.xml import participant_status_label
+
class TestEventXML(unittest.TestCase):
attendee = Attendee("jane@doe.org")
@@ -15,7 +16,7 @@ class TestEventXML(unittest.TestCase):
if (type(_value)) == _type:
return True
else:
- raise AssertionError, "%s != %s" % (type(_value), _type)
+ raise AssertionError("%s != %s" % (type(_value), _type))
def test_001_minimal(self):
self.assertIsInstance(self.attendee.__str__(), str)
@@ -46,13 +47,13 @@ class TestEventXML(unittest.TestCase):
def test_007_participant_status_map_reverse_lookup(self):
# Reverse lookups
- self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 0][0], "NEEDS-ACTION")
- self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 1][0], "ACCEPTED")
- self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 2][0], "DECLINED")
- self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 3][0], "TENTATIVE")
- self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 4][0], "DELEGATED")
- self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 5][0], "IN-PROCESS")
- self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 6][0], "COMPLETED")
+ self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 0][0], "NEEDS-ACTION")
+ self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 1][0], "ACCEPTED")
+ self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 2][0], "DECLINED")
+ self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 3][0], "TENTATIVE")
+ self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 4][0], "DELEGATED")
+ self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 5][0], "IN-PROCESS")
+ self.assertEqual([k for k, v in self.attendee.participant_status_map.iteritems() if v == 6][0], "COMPLETED")
def test_008_default_rsvp(self):
self.assertEqual(self.attendee.get_rsvp(), 0)
@@ -69,12 +70,12 @@ class TestEventXML(unittest.TestCase):
self.assertEqual(self.attendee.rsvp_map["FALSE"], 0)
def test_012_rsvp_map_reverse_lookup_boolean(self):
- self.assertEqual([k for k,v in self.attendee.rsvp_map.iteritems() if v == True][0], "TRUE")
- self.assertEqual([k for k,v in self.attendee.rsvp_map.iteritems() if v == False][0], "FALSE")
+ self.assertEqual([k for k, v in self.attendee.rsvp_map.iteritems() if v is True][0], "TRUE")
+ self.assertEqual([k for k, v in self.attendee.rsvp_map.iteritems() if v is False][0], "FALSE")
def test_013_rsvp_map_reverse_lookup_integer(self):
- self.assertEqual([k for k,v in self.attendee.rsvp_map.iteritems() if v == 1][0], "TRUE")
- self.assertEqual([k for k,v in self.attendee.rsvp_map.iteritems() if v == 0][0], "FALSE")
+ self.assertEqual([k for k, v in self.attendee.rsvp_map.iteritems() if v == 1][0], "TRUE")
+ self.assertEqual([k for k, v in self.attendee.rsvp_map.iteritems() if v == 0][0], "FALSE")
def test_014_default_role(self):
self.assertEqual(self.attendee.get_role(), 0)
@@ -89,10 +90,10 @@ class TestEventXML(unittest.TestCase):
self.assertEqual(self.attendee.role_map["NON-PARTICIPANT"], 3)
def test_017_role_map_reverse_lookup(self):
- self.assertEqual([k for k,v in self.attendee.role_map.iteritems() if v == 0][0], "REQ-PARTICIPANT")
- self.assertEqual([k for k,v in self.attendee.role_map.iteritems() if v == 1][0], "CHAIR")
- self.assertEqual([k for k,v in self.attendee.role_map.iteritems() if v == 2][0], "OPT-PARTICIPANT")
- self.assertEqual([k for k,v in self.attendee.role_map.iteritems() if v == 3][0], "NON-PARTICIPANT")
+ self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 0][0], "REQ-PARTICIPANT")
+ self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 1][0], "CHAIR")
+ self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 2][0], "OPT-PARTICIPANT")
+ self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 3][0], "NON-PARTICIPANT")
def test_015_cutype_map_length(self):
self.assertEqual(len(self.attendee.cutype_map.keys()), 3)
@@ -103,9 +104,9 @@ class TestEventXML(unittest.TestCase):
self.assertEqual(self.attendee.cutype_map["RESOURCE"], 3)
def test_017_cutype_map_reverse_lookup(self):
- self.assertEqual([k for k,v in self.attendee.cutype_map.iteritems() if v == 1][0], "GROUP")
- self.assertEqual([k for k,v in self.attendee.cutype_map.iteritems() if v == 2][0], "INDIVIDUAL")
- self.assertEqual([k for k,v in self.attendee.cutype_map.iteritems() if v == 3][0], "RESOURCE")
+ self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == 1][0], "GROUP")
+ self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == 2][0], "INDIVIDUAL")
+ self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == 3][0], "RESOURCE")
def test_018_partstat_label(self):
self.assertEqual(participant_status_label('NEEDS-ACTION'), "Needs Action")
diff --git a/tests/unit/test-003-event.py b/tests/unit/test-003-event.py
index 61fd888..18b186b 100644
--- a/tests/unit/test-003-event.py
+++ b/tests/unit/test-003-event.py
@@ -332,6 +332,7 @@ xml_event = """
</icalendar>
"""
+
class TestEventXML(unittest.TestCase):
event = Event()
@@ -353,10 +354,10 @@ class TestEventXML(unittest.TestCase):
if (type(_value)) == _type:
return True
else:
- if not _msg == None:
- raise AssertionError, "%s != %s: %r" % (type(_value), _type, _msg)
+ if _msg is not None:
+ raise AssertionError("%s != %s: %r" % (type(_value), _type, _msg))
else:
- raise AssertionError, "%s != %s" % (type(_value), _type)
+ raise AssertionError("%s != %s" % (type(_value), _type))
def test_000_no_start_date(self):
self.assertRaises(EventIntegrityError, self.event.__str__)
@@ -442,8 +443,8 @@ class TestEventXML(unittest.TestCase):
def test_016_start_with_timezone(self):
_start = datetime.datetime(2012, 05, 23, 11, 58, 00, tzinfo=pytz.timezone("Europe/Zurich"))
_start_utc = _start.astimezone(pytz.utc)
- #self.assertEqual(_start.__str__(), "2012-05-23 11:58:00+01:00")
- #self.assertEqual(_start_utc.__str__(), "2012-05-23 10:58:00+00:00")
+ # self.assertEqual(_start.__str__(), "2012-05-23 11:58:00+01:00")
+ # self.assertEqual(_start_utc.__str__(), "2012-05-23 10:58:00+00:00")
self.event.set_start(_start)
self.assertIsInstance(_start.tzinfo, datetime.tzinfo)
self.assertEqual(_start.tzinfo, pytz.timezone("Europe/Zurich"))
@@ -452,7 +453,7 @@ class TestEventXML(unittest.TestCase):
_start = datetime.date(2012, 05, 23)
self.assertEqual(_start.__str__(), "2012-05-23")
self.event.set_start(_start)
- self.assertEqual(hasattr(_start,'tzinfo'), False)
+ self.assertEqual(hasattr(_start, 'tzinfo'), False)
self.assertEqual(self.event.get_start().__str__(), "2012-05-23")
def test_018_load_from_ical(self):
@@ -501,7 +502,7 @@ METHOD:REQUEST
self.assertEqual(message['X-Kolab-Type'], 'application/x-vnd.kolab.event')
parts = [p for p in message.walk()]
- attachments = event.get_attachments();
+ attachments = event.get_attachments()
self.assertEqual(len(parts), 5)
self.assertEqual(parts[1].get_content_type(), 'text/plain')
@@ -542,11 +543,11 @@ END:VEVENT
rrule = RecurrenceRule()
rrule.set_frequency(kolabformat.RecurrenceRule.Weekly)
- rrule.set_byday(['2WE','-1SU'])
+ rrule.set_byday(['2WE', '-1SU'])
rrule.setBymonth([2])
rrule.set_count(10)
- rrule.set_until(datetime.datetime(2014,7,23, 11,0,0, tzinfo=pytz.timezone("Europe/London")))
- self.event.set_recurrence(rrule);
+ rrule.set_until(datetime.datetime(2014, 7, 23, 11, 0, 0, tzinfo=pytz.timezone("Europe/London")))
+ self.event.set_recurrence(rrule)
ical = icalendar.Calendar.from_ical(self.event.as_string_itip())
event = ical.walk('VEVENT')[0]
@@ -560,12 +561,12 @@ END:VEVENT
self.assertIsInstance(event['recurrence-id'].dt, datetime.datetime)
self.assertEqual(event['recurrence-id'].params.get('RANGE'), 'THISANDFUTURE')
- self.assertTrue(event.has_key('rrule'))
+ self.assertTrue('rrule' in event)
self.assertEqual(event['rrule']['FREQ'][0], 'WEEKLY')
self.assertEqual(event['rrule']['INTERVAL'][0], 1)
self.assertEqual(event['rrule']['COUNT'][0], 10)
self.assertEqual(event['rrule']['BYMONTH'][0], 2)
- self.assertEqual(event['rrule']['BYDAY'], ['2WE','-1SU'])
+ self.assertEqual(event['rrule']['BYDAY'], ['2WE', '-1SU'])
self.assertIsInstance(event['rrule']['UNTIL'][0], datetime.datetime)
self.assertEquals(event['rrule']['UNTIL'][0].tzinfo, pytz.utc)
@@ -606,14 +607,13 @@ END:VEVENT
self.assertEqual(itip_event['attendee'][0].params['delegated-to'], 'jack@ripper.com')
self.assertEqual(itip_event['attendee'][1].params['delegated-from'], 'jane@doe.org')
-
def test_020_calendaring_recurrence(self):
rrule = kolabformat.RecurrenceRule()
rrule.setFrequency(kolabformat.RecurrenceRule.Monthly)
rrule.setCount(10)
self.event = Event()
- self.event.set_recurrence(rrule);
+ self.event.set_recurrence(rrule)
_start = datetime.datetime(2014, 5, 1, 11, 30, 00, tzinfo=pytz.timezone("Europe/London"))
self.event.set_start(_start)
@@ -643,7 +643,7 @@ END:VEVENT
# check infinite recurrence
rrule = kolabformat.RecurrenceRule()
rrule.setFrequency(kolabformat.RecurrenceRule.Monthly)
- self.event.set_recurrence(rrule);
+ self.event.set_recurrence(rrule)
self.assertEqual(self.event.get_last_occurrence(), None)
self.assertIsInstance(self.event.get_last_occurrence(force=True), datetime.datetime)
@@ -659,7 +659,7 @@ END:VEVENT
# check get_next_occurence() with an infinitely recurring all-day event
rrule = kolabformat.RecurrenceRule()
rrule.setFrequency(kolabformat.RecurrenceRule.Yearly)
- self.event.set_recurrence(rrule);
+ self.event.set_recurrence(rrule)
self.event.set_start(datetime.date(2014, 5, 1))
self.event.set_end(datetime.date(2014, 5, 1))
@@ -701,13 +701,13 @@ END:VEVENT
self.event = Event()
self.event.set_summary('alldays')
- self.event.set_recurrence(rrule);
+ self.event.set_recurrence(rrule)
- _start = datetime.date(2015,1,1)
+ _start = datetime.date(2015, 1, 1)
self.event.set_start(_start)
self.event.set_end(_start)
- exdate = datetime.date(2015,1,5)
+ exdate = datetime.date(2015, 1, 5)
xmlexception = Event(from_string=str(self.event))
xmlexception.set_start(exdate)
xmlexception.set_end(exdate)
@@ -715,8 +715,8 @@ END:VEVENT
xmlexception.set_status('CANCELLED')
self.event.add_exception(xmlexception)
- inst3 = self.event.get_instance(datetime.date(2015,1,3))
- self.assertEqual(inst3.get_start(), datetime.date(2015,1,3))
+ inst3 = self.event.get_instance(datetime.date(2015, 1, 3))
+ self.assertEqual(inst3.get_start(), datetime.date(2015, 1, 3))
inst5 = self.event.get_instance(exdate)
self.assertEqual(inst5.get_status(True), 'CANCELLED')
@@ -752,12 +752,12 @@ END:VEVENT
self.event = Event()
self.event.set_summary('singles')
- _start = datetime.datetime(2015,3,1, 14,0,0, tzinfo=pytz.timezone("Europe/London"))
+ _start = datetime.datetime(2015, 3, 1, 14, 0, 0, tzinfo=pytz.timezone("Europe/London"))
self.event.set_start(_start)
self.event.set_end(_start + datetime.timedelta(hours=1))
self.event.set_recurrence_id(_start)
- _start2 = datetime.datetime(2015,3,5, 15,0,0, tzinfo=pytz.timezone("Europe/London"))
+ _start2 = datetime.datetime(2015, 3, 5, 15, 0, 0, tzinfo=pytz.timezone("Europe/London"))
xmlexception = Event(from_string=str(self.event))
xmlexception.set_start(_start2)
xmlexception.set_end(_start2 + datetime.timedelta(hours=1))
@@ -785,7 +785,6 @@ END:VEVENT
self.assertEqual(event.get_status(True), 'CANCELLED')
self.assertEqual(event.get_summary(), "singles #1")
-
def test_022_load_from_xml(self):
event = event_from_string(xml_event)
self.assertEqual(event.uid, '75c740bb-b3c6-442c-8021-ecbaeb0a025e')
@@ -820,10 +819,10 @@ END:VEVENT
self.assertEqual(str(occurrence.get_recurrence_id()), "2014-08-15 10:00:00+01:00")
# set invalid date-only recurrence-id
- exception.set_recurrence_id(datetime.date(2014,8,16))
+ exception.set_recurrence_id(datetime.date(2014, 8, 16))
event.add_exception(exception)
- inst = event.get_next_instance(_recurrence_id);
+ inst = event.get_next_instance(_recurrence_id)
self.assertIsInstance(inst, Event)
self.assertIsInstance(inst.get_recurrence_id(), datetime.datetime)
@@ -836,7 +835,7 @@ END:VEVENT
# check attachment MIME parts are kept
parts = [p for p in message.walk()]
- attachments = event.get_attachments();
+ attachments = event.get_attachments()
self.assertEqual(len(parts), 5)
self.assertEqual(parts[3].get_content_type(), 'image/png')
@@ -871,7 +870,7 @@ END:VEVENT
self.assertIsInstance(data, dict)
self.assertIsInstance(data['start'], datetime.datetime)
- #self.assertIsInstance(data['end'], datetime.datetime)
+ # self.assertIsInstance(data['end'], datetime.datetime)
self.assertIsInstance(data['created'], datetime.datetime)
self.assertIsInstance(data['lastmodified-date'], datetime.datetime)
self.assertEqual(data['uid'], '75c740bb-b3c6-442c-8021-ecbaeb0a025e')
@@ -929,7 +928,6 @@ END:VEVENT
self.assertEqual(pa['index'], 0)
self.assertEqual(pa['new'], dict(partstat='DECLINED'))
-
def test_026_property_to_string(self):
data = event_from_string(xml_event).to_dict()
self.assertEqual(property_to_string('sequence', data['sequence']), "1")
@@ -941,7 +939,6 @@ END:VEVENT
self.assertEqual(property_to_string('alarm', data['alarm'][0]), "Display message 2 hour(s) before")
self.assertEqual(property_to_string('attach', data['attach'][0]), "noname.1395223627.5555")
-
def test_027_merge_attendee_data(self):
event = event_from_string(xml_event)
@@ -951,7 +948,7 @@ END:VEVENT
some = event.set_attendee_participant_status("somebody@else.com", 'ACCEPTED')
# update jane + add jack
- event.update_attendees([jane,jack])
+ event.update_attendees([jane, jack])
self.assertEqual(len(event.get_attendees()), 3)
self.assertEqual(event.get_attendee("jane@example.org").get_participant_status(), kolabformat.PartTentative)
self.assertEqual(event.get_attendee("somebody@else.com").get_participant_status(), kolabformat.PartAccepted)
@@ -964,7 +961,6 @@ END:VEVENT
self.assertEqual(event.get_attendee("jack@example.org").get_name(), "Jack")
self.assertRaises(ValueError, exception.get_attendee, "somebody@else.com") # not addded to exception
-
def _find_prop_in_list(self, diff, name):
for prop in diff:
if prop['property'] == name:
diff --git a/tests/unit/test-004-icalendar.py b/tests/unit/test-004-icalendar.py
index 6033a33..519599b 100644
--- a/tests/unit/test-004-icalendar.py
+++ b/tests/unit/test-004-icalendar.py
@@ -2,6 +2,7 @@ from email import message_from_string
import icalendar
import unittest
+
class TestICalendar(unittest.TestCase):
def test_001_from_message_recurrence(self):
@@ -89,16 +90,15 @@ END:VCALENDAR
self.assertTrue(message.is_multipart())
- itip_methods = [ "REQUEST" ]
+ itip_methods = ["REQUEST"]
# Check each part
for part in message.walk():
-
# The iTip part MUST be Content-Type: text/calendar (RFC 6047,
# section 2.4)
if part.get_content_type() == "text/calendar":
if not part.get_param('method') in itip_methods:
- raise Exception, "method not interesting"
+ raise Exception("method not interesting")
# Get the itip_payload
itip_payload = part.get_payload(decode=True)
@@ -196,16 +196,15 @@ END:VCALENDAR
self.assertTrue(message.is_multipart())
- itip_methods = [ "REQUEST" ]
+ itip_methods = ["REQUEST"]
# Check each part
for part in message.walk():
-
# The iTip part MUST be Content-Type: text/calendar (RFC 6047,
# section 2.4)
if part.get_content_type() == "text/calendar":
if not part.get_param('method') in itip_methods:
- raise Exception, "method not interesting"
+ raise Exception("method not interesting")
# Get the itip_payload
itip_payload = part.get_payload(decode=True)
diff --git a/tests/unit/test-005-timezone.py b/tests/unit/test-005-timezone.py
index fc67eaa..47a6947 100644
--- a/tests/unit/test-005-timezone.py
+++ b/tests/unit/test-005-timezone.py
@@ -11,10 +11,11 @@ from pykolab.xml import InvalidAttendeeParticipantStatusError
from pykolab.xml import InvalidEventDateError
from pykolab.xml import event_from_ical
+
class TestTimezone(unittest.TestCase):
def test_001_timezone_conflict(self):
- #class datetime.timedelta([days[, seconds[, microseconds[, milliseconds[, minutes[, hours[, weeks]]]]]]])
+ # class datetime.timedelta([days[, seconds[, microseconds[, milliseconds[, minutes[, hours[, weeks]]]]]]])
tdelta = datetime.timedelta(0, 0, 0, 0, 0, 1)
event_start = datetime.datetime.now(pytz.timezone("UTC"))
@@ -37,16 +38,16 @@ class TestTimezone(unittest.TestCase):
london_xml = london.__str__()
zurich_xml = zurich.__str__()
- #print london_xml
- #print zurich_xml
+ # print london_xml
+ # print zurich_xml
london_itip = london.as_string_itip()
zurich_itip = zurich.as_string_itip()
del london, zurich
- #print london_itip
- #print zurich_itip
+ # print london_itip
+ # print zurich_itip
london_cal = icalendar.Calendar.from_ical(london_itip)
london = event_from_ical(london_cal.walk('VEVENT')[0].to_ical())
@@ -54,22 +55,21 @@ class TestTimezone(unittest.TestCase):
zurich_cal = icalendar.Calendar.from_ical(zurich_itip)
zurich = event_from_ical(zurich_cal.walk('VEVENT')[0].to_ical())
- #fp = open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'event-london1')), 'w')
- #fp.write(london_xml)
- #fp.close()
+ # fp = open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'event-london1')), 'w')
+ # fp.write(london_xml)
+ # fp.close()
- #fp = open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'event-london2')), 'w')
- #fp.write(london.__str__())
- #fp.close()
+ # fp = open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'event-london2')), 'w')
+ # fp.write(london.__str__())
+ # fp.close()
- #fp = open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'event-zurich1')), 'w')
- #fp.write(zurich_xml)
- #fp.close()
+ # fp = open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'event-zurich1')), 'w')
+ # fp.write(zurich_xml)
+ # fp.close()
- #fp = open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'event-zurich2')), 'w')
- #fp.write(zurich.__str__())
- #fp.close()
+ # fp = open(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'event-zurich2')), 'w')
+ # fp.write(zurich.__str__())
+ # fp.close()
self.assertEqual(london_xml, london.__str__())
self.assertEqual(zurich_xml, zurich.__str__())
-
diff --git a/tests/unit/test-006-ldap_psearch.py b/tests/unit/test-006-ldap_psearch.py
index 9b4e0cd..5e082b3 100644
--- a/tests/unit/test-006-ldap_psearch.py
+++ b/tests/unit/test-006-ldap_psearch.py
@@ -1,5 +1,6 @@
import unittest
+
class TestLDAPPsearch(unittest.TestCase):
def test_001_import_psearch(self):
diff --git a/tests/unit/test-007-ldap_syncrepl.py b/tests/unit/test-007-ldap_syncrepl.py
index e09579f..d80efea 100644
--- a/tests/unit/test-007-ldap_syncrepl.py
+++ b/tests/unit/test-007-ldap_syncrepl.py
@@ -1,5 +1,6 @@
import unittest
+
class TestLDAPSyncrepl(unittest.TestCase):
def test_001_import_syncrepl(self):
diff --git a/tests/unit/test-008-sievelib.py b/tests/unit/test-008-sievelib.py
index cd4eb3b..9226ad6 100644
--- a/tests/unit/test-008-sievelib.py
+++ b/tests/unit/test-008-sievelib.py
@@ -38,6 +38,7 @@ if allof (header :contains "X-Mailer" "OTRS", header :contains "X-Powered-By" "O
]
+
class TestSievelib(unittest.TestCase):
def test_001_import_sievelib(self):
@@ -53,4 +54,4 @@ class TestSievelib(unittest.TestCase):
result = sieve_parser.parse(sieve_str)
if not result:
print "Sieve line: %r" % (sieve_parser.lexer.text.split('\n')[(sieve_parser.lexer.text[:sieve_parser.lexer.pos].count('\n'))])
- raise Exception, "Failed parsing Sieve script #%d: %s" % (i, sieve_parser.error)
+ raise Exception("Failed parsing Sieve script #%d: %s" % (i, sieve_parser.error))
diff --git a/tests/unit/test-009-parse_ldap_uri.py b/tests/unit/test-009-parse_ldap_uri.py
index d020f8d..2596ddd 100644
--- a/tests/unit/test-009-parse_ldap_uri.py
+++ b/tests/unit/test-009-parse_ldap_uri.py
@@ -2,6 +2,7 @@ import unittest
from pykolab import utils
+
class TestParseLdapUri(unittest.TestCase):
def test_001_ldap_uri(self):
@@ -13,5 +14,3 @@ class TestParseLdapUri(unittest.TestCase):
ldap_uri = "ldap://localhost:389"
result = utils.parse_ldap_uri(ldap_uri)
self.assertEqual(result, ("ldap", "localhost", "389", None, None, None, None))
-
-
diff --git a/tests/unit/test-010-transliterate.py b/tests/unit/test-010-transliterate.py
index e6b9000..87e4b84 100644
--- a/tests/unit/test-010-transliterate.py
+++ b/tests/unit/test-010-transliterate.py
@@ -2,6 +2,7 @@
import unittest
+
class TestTransliteration(unittest.TestCase):
def test_001_raw_fr_FR(self):
"""
diff --git a/tests/unit/test-011-itip.py b/tests/unit/test-011-itip.py
index 08d9949..38e00b8 100644
--- a/tests/unit/test-011-itip.py
+++ b/tests/unit/test-011-itip.py
@@ -99,7 +99,7 @@ itip_google_multipart = """MIME-Version: 1.0
Message-ID: <001a11c2ad84243e0604f3246bae@google.com>
Date: Mon, 24 Feb 2014 10:27:28 +0000
Subject: =?ISO-8859-1?Q?Invitation=3A_iTip_from_Apple_=40_Mon_Feb_24=2C_2014_12pm_?=
- =?ISO-8859-1?Q?=2D_1pm_=28Tom_=26_T=E4m=29?=
+ =?ISO-8859-1?Q?=2D_1pm_=28Tom_=26_T=E4m=29?=
From: "john.doe" <john.doe@gmail.com>
To: <john.sample@example.org>
Content-Type: multipart/mixed; boundary=001a11c2ad84243df004f3246bad
@@ -321,6 +321,7 @@ conf = pykolab.getConf()
if not hasattr(conf, 'defaults'):
conf.finalize_conf()
+
class TestITip(unittest.TestCase):
def setUp(self):
@@ -330,7 +331,7 @@ class TestITip(unittest.TestCase):
self.patch(smtplib.SMTP, "quit", self._mock_nop)
self.patch(smtplib.SMTP, "sendmail", self._mock_smtp_sendmail)
- self.smtplog = [];
+ self.smtplog = []
def _mock_nop(self, domain=None):
pass
@@ -341,7 +342,6 @@ class TestITip(unittest.TestCase):
def _mock_smtp_sendmail(self, from_addr, to_addr, message, mail_options=None, rcpt_options=None):
self.smtplog.append((from_addr, to_addr, message))
-
def test_001_itip_events_from_message(self):
itips1 = itip.events_from_message(message_from_string(itip_multipart))
self.assertEqual(len(itips1), 1, "Multipart iTip message with text/calendar")
@@ -375,42 +375,40 @@ class TestITip(unittest.TestCase):
self.assertEqual(xml.get_summary(), "Testing Ümlauts")
self.assertEqual(xml.get_location(), "Rue the Genève")
-
def test_002_check_date_conflict(self):
- astart = datetime.datetime(2014,7,13, 10,0,0)
- aend = astart + datetime.timedelta(hours=2)
+ astart = datetime.datetime(2014, 7, 13, 10, 0, 0)
+ aend = astart + datetime.timedelta(hours=2)
- bstart = datetime.datetime(2014,7,13, 10,0,0)
- bend = astart + datetime.timedelta(hours=1)
+ bstart = datetime.datetime(2014, 7, 13, 10, 0, 0)
+ bend = astart + datetime.timedelta(hours=1)
self.assertTrue(itip.check_date_conflict(astart, aend, bstart, bend))
- bstart = datetime.datetime(2014,7,13, 11,0,0)
- bend = astart + datetime.timedelta(minutes=30)
+ bstart = datetime.datetime(2014, 7, 13, 11, 0, 0)
+ bend = astart + datetime.timedelta(minutes=30)
self.assertTrue(itip.check_date_conflict(astart, aend, bstart, bend))
- bend = astart + datetime.timedelta(hours=2)
+ bend = astart + datetime.timedelta(hours=2)
self.assertTrue(itip.check_date_conflict(astart, aend, bstart, bend))
- bstart = datetime.datetime(2014,7,13, 12,0,0)
- bend = astart + datetime.timedelta(hours=1)
+ bstart = datetime.datetime(2014, 7, 13, 12, 0, 0)
+ bend = astart + datetime.timedelta(hours=1)
self.assertFalse(itip.check_date_conflict(astart, aend, bstart, bend))
self.assertFalse(itip.check_date_conflict(bstart, bend, astart, aend))
- bstart = datetime.datetime(2014,6,13, 10,0,0)
- bend = datetime.datetime(2014,6,14, 12,0,0)
+ bstart = datetime.datetime(2014, 6, 13, 10, 0, 0)
+ bend = datetime.datetime(2014, 6, 14, 12, 0, 0)
self.assertFalse(itip.check_date_conflict(astart, aend, bstart, bend))
- bstart = datetime.datetime(2014,7,10, 12,0,0)
- bend = datetime.datetime(2014,7,14, 14,0,0)
+ bstart = datetime.datetime(2014, 7, 10, 12, 0, 0)
+ bend = datetime.datetime(2014, 7, 14, 14, 0, 0)
self.assertTrue(itip.check_date_conflict(astart, aend, bstart, bend))
-
def test_002_check_event_conflict(self):
itip_event = itip.events_from_message(message_from_string(itip_non_multipart))[0]
event = Event()
- event.set_start(datetime.datetime(2012,7,13, 9,30,0, tzinfo=itip_event['start'].tzinfo))
- event.set_end(datetime.datetime(2012,7,13, 10,30,0, tzinfo=itip_event['start'].tzinfo))
+ event.set_start(datetime.datetime(2012, 7, 13, 9, 30, 0, tzinfo=itip_event['start'].tzinfo))
+ event.set_end(datetime.datetime(2012, 7, 13, 10, 30, 0, tzinfo=itip_event['start'].tzinfo))
self.assertTrue(itip.check_event_conflict(event, itip_event), "Conflicting dates")
@@ -418,8 +416,8 @@ class TestITip(unittest.TestCase):
self.assertFalse(itip.check_event_conflict(event, itip_event), "No conflict for same UID")
allday = Event()
- allday.set_start(datetime.date(2012,7,13))
- allday.set_end(datetime.date(2012,7,13))
+ allday.set_start(datetime.date(2012, 7, 13))
+ allday.set_end(datetime.date(2012, 7, 13))
self.assertTrue(itip.check_event_conflict(allday, itip_event), "Conflicting allday event")
@@ -427,8 +425,8 @@ class TestITip(unittest.TestCase):
self.assertFalse(itip.check_event_conflict(allday, itip_event), "No conflict if event is set to transparent")
event2 = Event()
- event2.set_start(datetime.datetime(2012,7,13, 10,0,0, tzinfo=pytz.timezone("US/Central")))
- event2.set_end(datetime.datetime(2012,7,13, 11,0,0, tzinfo=pytz.timezone("US/Central")))
+ event2.set_start(datetime.datetime(2012, 7, 13, 10, 0, 0, tzinfo=pytz.timezone("US/Central")))
+ event2.set_end(datetime.datetime(2012, 7, 13, 11, 0, 0, tzinfo=pytz.timezone("US/Central")))
self.assertFalse(itip.check_event_conflict(event, itip_event), "No conflict with timezone shift")
@@ -437,9 +435,9 @@ class TestITip(unittest.TestCase):
rrule.setCount(10)
event3 = Event()
- event3.set_recurrence(rrule);
- event3.set_start(datetime.datetime(2012,6,29, 9,30,0, tzinfo=pytz.utc))
- event3.set_end(datetime.datetime(2012,6,29, 10,30,0, tzinfo=pytz.utc))
+ event3.set_recurrence(rrule)
+ event3.set_start(datetime.datetime(2012, 6, 29, 9, 30, 0, tzinfo=pytz.utc))
+ event3.set_end(datetime.datetime(2012, 6, 29, 10, 30, 0, tzinfo=pytz.utc))
self.assertTrue(itip.check_event_conflict(event3, itip_event), "Conflict in (3rd) recurring event instance")
@@ -447,9 +445,9 @@ class TestITip(unittest.TestCase):
self.assertTrue(itip.check_event_conflict(event3, itip_event), "Conflict in two recurring events")
event4 = Event()
- event4.set_recurrence(rrule);
- event4.set_start(datetime.datetime(2012,7,1, 9,30,0, tzinfo=pytz.utc))
- event4.set_end(datetime.datetime(2012,7,1, 10,30,0, tzinfo=pytz.utc))
+ event4.set_recurrence(rrule)
+ event4.set_start(datetime.datetime(2012, 7, 1, 9, 30, 0, tzinfo=pytz.utc))
+ event4.set_end(datetime.datetime(2012, 7, 1, 10, 30, 0, tzinfo=pytz.utc))
self.assertFalse(itip.check_event_conflict(event4, itip_event), "No conflict in two recurring events")
itip_event = itip.events_from_message(message_from_string(itip_non_multipart))[0]
@@ -458,23 +456,23 @@ class TestITip(unittest.TestCase):
rrule.setCount(10)
event5 = Event()
- event5.set_recurrence(rrule);
- event5.set_start(datetime.datetime(2012,7,9, 10,0,0, tzinfo=pytz.timezone("Europe/London")))
- event5.set_end(datetime.datetime(2012,7,9, 11,0,0, tzinfo=pytz.timezone("Europe/London")))
+ event5.set_recurrence(rrule)
+ event5.set_start(datetime.datetime(2012, 7, 9, 10, 0, 0, tzinfo=pytz.timezone("Europe/London")))
+ event5.set_end(datetime.datetime(2012, 7, 9, 11, 0, 0, tzinfo=pytz.timezone("Europe/London")))
event_xml = str(event5)
exception = Event(from_string=event_xml)
- exception.set_start(datetime.datetime(2012,7,13, 14,0,0, tzinfo=pytz.timezone("Europe/London")))
- exception.set_end(datetime.datetime(2012,7,13, 16,0,0, tzinfo=pytz.timezone("Europe/London")))
- exception.set_recurrence_id(datetime.datetime(2012,7,13, 10,0,0, tzinfo=pytz.timezone("Europe/London")), False)
+ exception.set_start(datetime.datetime(2012, 7, 13, 14, 0, 0, tzinfo=pytz.timezone("Europe/London")))
+ exception.set_end(datetime.datetime(2012, 7, 13, 16, 0, 0, tzinfo=pytz.timezone("Europe/London")))
+ exception.set_recurrence_id(datetime.datetime(2012, 7, 13, 10, 0, 0, tzinfo=pytz.timezone("Europe/London")), False)
event5.add_exception(exception)
self.assertFalse(itip.check_event_conflict(event5, itip_event), "No conflict with exception date")
exception = Event(from_string=event_xml)
- exception.set_start(datetime.datetime(2012,7,13, 10,0,0, tzinfo=pytz.timezone("Europe/London")))
- exception.set_end(datetime.datetime(2012,7,13, 11,0,0, tzinfo=pytz.timezone("Europe/London")))
+ exception.set_start(datetime.datetime(2012, 7, 13, 10, 0, 0, tzinfo=pytz.timezone("Europe/London")))
+ exception.set_end(datetime.datetime(2012, 7, 13, 11, 0, 0, tzinfo=pytz.timezone("Europe/London")))
exception.set_status('CANCELLED')
- exception.set_recurrence_id(datetime.datetime(2012,7,13, 10,0,0, tzinfo=pytz.timezone("Europe/London")), False)
+ exception.set_recurrence_id(datetime.datetime(2012, 7, 13, 10, 0, 0, tzinfo=pytz.timezone("Europe/London")), False)
event5.add_exception(exception)
self.assertFalse(itip.check_event_conflict(event5, itip_event), "No conflict with cancelled exception")
@@ -482,11 +480,11 @@ class TestITip(unittest.TestCase):
itip_event = itip.events_from_message(message_from_string(itip_non_multipart))[0]
event = Event()
- event.set_start(datetime.datetime(2012,7,10, 9,30,0, tzinfo=itip_event['start'].tzinfo))
- event.set_end(datetime.datetime(2012,7,10, 10,30,0, tzinfo=itip_event['start'].tzinfo))
+ event.set_start(datetime.datetime(2012, 7, 10, 9, 30, 0, tzinfo=itip_event['start'].tzinfo))
+ event.set_end(datetime.datetime(2012, 7, 10, 10, 30, 0, tzinfo=itip_event['start'].tzinfo))
event.set_recurrence_id(event.get_start())
- dtstart = datetime.datetime(2012,7,13, 9,30,0, tzinfo=itip_event['start'].tzinfo)
+ dtstart = datetime.datetime(2012, 7, 13, 9, 30, 0, tzinfo=itip_event['start'].tzinfo)
second = Event(from_string=str(event))
second.set_start(dtstart)
second.set_end(dtstart + datetime.timedelta(hours=1))
@@ -497,7 +495,7 @@ class TestITip(unittest.TestCase):
itip_event = itip.events_from_message(message_from_string(itip_non_multipart))[0]
- dtstart = datetime.datetime(2012,7,15, 10,0,0, tzinfo=itip_event['start'].tzinfo)
+ dtstart = datetime.datetime(2012, 7, 15, 10, 0, 0, tzinfo=itip_event['start'].tzinfo)
second = Event(from_string=str(itip_event['xml']))
second.set_start(dtstart + datetime.timedelta(hours=1))
second.set_end(dtstart + datetime.timedelta(hours=2))
@@ -507,18 +505,17 @@ class TestITip(unittest.TestCase):
self.assertEqual(len(itip_event['xml'].get_exceptions()), 1)
event = Event()
- event.set_start(datetime.datetime(2012,7,11, 9,30,0, tzinfo=itip_event['start'].tzinfo))
- event.set_end(datetime.datetime(2012,7,11, 10,30,0, tzinfo=itip_event['start'].tzinfo))
+ event.set_start(datetime.datetime(2012, 7, 11, 9, 30, 0, tzinfo=itip_event['start'].tzinfo))
+ event.set_end(datetime.datetime(2012, 7, 11, 10, 30, 0, tzinfo=itip_event['start'].tzinfo))
self.assertFalse(itip.check_event_conflict(event, itip_event), "Conflicting dates (no)")
event = Event()
- event.set_start(datetime.datetime(2012,7,15, 11,0,0, tzinfo=itip_event['start'].tzinfo))
- event.set_end(datetime.datetime(2012,7,15, 11,30,0, tzinfo=itip_event['start'].tzinfo))
+ event.set_start(datetime.datetime(2012, 7, 15, 11, 0, 0, tzinfo=itip_event['start'].tzinfo))
+ event.set_end(datetime.datetime(2012, 7, 15, 11, 30, 0, tzinfo=itip_event['start'].tzinfo))
self.assertFalse(itip.check_event_conflict(event, itip_event), "Conflicting dates (exception)")
-
def test_003_send_reply(self):
itip_events = itip.events_from_message(message_from_string(itip_non_multipart))
itip.send_reply("resource-collection-car@example.org", itip_events, "SUMMARY=%(summary)s; STATUS=%(status)s; NAME=%(name)s;")
@@ -529,9 +526,9 @@ class TestITip(unittest.TestCase):
_accepted = participant_status_label('ACCEPTED')
message = message_from_string(self.smtplog[0][2])
- self.assertEqual(message.get('Subject'), _("Invitation for %(summary)s was %(status)s") % { 'summary':'test', 'status':_accepted })
+ self.assertEqual(message.get('Subject'), _("Invitation for %(summary)s was %(status)s") % {'summary': 'test', 'status': _accepted})
- text = str(message.get_payload(0));
+ text = str(message.get_payload(0))
self.assertIn('SUMMARY=3Dtest', text)
self.assertIn('STATUS=3D' + _accepted, text)
diff --git a/tests/unit/test-011-wallace_resources.py b/tests/unit/test-011-wallace_resources.py
index dd7834b..01ef0d1 100644
--- a/tests/unit/test-011-wallace_resources.py
+++ b/tests/unit/test-011-wallace_resources.py
@@ -93,6 +93,7 @@ conf = pykolab.getConf()
if not hasattr(conf, 'defaults'):
conf.finalize_conf()
+
class TestWallaceResources(unittest.TestCase):
def setUp(self):
@@ -110,27 +111,27 @@ class TestWallaceResources(unittest.TestCase):
self.patch(smtplib.SMTP, "quit", self._mock_nop)
self.patch(smtplib.SMTP, "sendmail", self._mock_smtp_sendmail)
- self.smtplog = [];
+ self.smtplog = []
def _mock_nop(self, domain=None):
pass
def _mock_find_resource(self, address):
- if not 'resource' in address:
- return [];
+ if 'resource' not in address:
+ return []
(prefix, domain) = address.split('@')
entry_dn = "cn=" + prefix + ",ou=Resources,dc=" + ",dc=".join(domain.split('.'))
- return [ entry_dn ];
+ return [entry_dn]
def _mock_get_entry_attributes(self, domain, entry, attributes):
(_, uid) = entry.split(',')[0].split('=')
- return { 'cn': uid, 'mail': uid + "@example.org", '_attrib': attributes }
+ return {'cn': uid, 'mail': uid + "@example.org", '_attrib': attributes}
def _mock_search_entry_by_attribute(self, attr, value, **kw):
results = []
if value == "cn=Room 101,ou=Resources,dc=example,dc=org":
- results.append(('cn=Rooms,ou=Resources,dc=example,dc=org', { attr: value, 'owner': 'uid=doe,ou=People,dc=example,dc=org' }))
+ results.append(('cn=Rooms,ou=Resources,dc=example,dc=org', {attr: value, 'owner': 'uid=doe,ou=People,dc=example,dc=org'}))
return results
def _mock_smtp_init(self, host=None, port=None, local_hostname=None, timeout=0):
@@ -159,45 +160,42 @@ class TestWallaceResources(unittest.TestCase):
return None
-
def test_002_resource_record_from_email_address(self):
res = module_resources.resource_record_from_email_address("doe@example.org")
- self.assertEqual(len(res), 0);
+ self.assertEqual(len(res), 0)
def test_003_resource_records_from_itip_events(self):
message = message_from_string(itip_multipart)
itips = itip.events_from_message(message)
res = module_resources.resource_records_from_itip_events(itips)
- self.assertEqual(len(res), 2, "Return resources: %r" % (res));
+ self.assertEqual(len(res), 2, "Return resources: %r" % (res))
res = module_resources.resource_records_from_itip_events(itips, message['To'])
- self.assertEqual(len(res), 1, "Return target resource: %r" % (res));
- self.assertEqual("cn=resource-collection-car,ou=Resources,dc=example,dc=org", res[0]);
-
+ self.assertEqual(len(res), 1, "Return target resource: %r" % (res))
+ self.assertEqual("cn=resource-collection-car,ou=Resources,dc=example,dc=org", res[0])
def test_004_get_resource_owner(self):
- owner1 = module_resources.get_resource_owner({ 'owner': "uid=foo,ou=People,cd=example,dc=org" })
+ owner1 = module_resources.get_resource_owner({'owner': "uid=foo,ou=People,cd=example,dc=org"})
self.assertIsInstance(owner1, dict)
self.assertEqual("foo@example.org", owner1['mail'])
self.assertIn("telephoneNumber", owner1['_attrib'])
- owner2 = module_resources.get_resource_owner({ 'owner': ["uid=john,ou=People,cd=example,dc=org", "uid=jane,ou=People,cd=example,dc=org"] })
+ owner2 = module_resources.get_resource_owner({'owner': ["uid=john,ou=People,cd=example,dc=org", "uid=jane,ou=People,cd=example,dc=org"]})
self.assertIsInstance(owner2, dict)
self.assertEqual("john@example.org", owner2['mail'])
- owner3 = module_resources.get_resource_owner({ 'dn': "cn=cars,ou=Resources,cd=example,dc=org" })
+ owner3 = module_resources.get_resource_owner({'dn': "cn=cars,ou=Resources,cd=example,dc=org"})
self.assertEqual(owner3, None)
- owner4 = module_resources.get_resource_owner({ 'dn': "cn=Room 101,ou=Resources,dc=example,dc=org" })
+ owner4 = module_resources.get_resource_owner({'dn': "cn=Room 101,ou=Resources,dc=example,dc=org"})
self.assertEqual("doe@example.org", owner4['mail'])
-
def test_005_send_response_accept(self):
itip_event = itip.events_from_message(message_from_string(itip_non_multipart))
module_resources.send_response("resource-collection-car@example.org", itip_event)
- self.assertEqual(len(self.smtplog), 1);
+ self.assertEqual(len(self.smtplog), 1)
self.assertEqual("resource-collection-car@example.org", self.smtplog[0][0])
self.assertEqual("doe@example.org", self.smtplog[0][1])
@@ -210,7 +208,6 @@ class TestWallaceResources(unittest.TestCase):
self.assertIsInstance(ics_part, message.Message)
self.assertEqual(ics_part.get_param('method'), "REPLY")
-
def test_006_send_response_delegate(self):
# delegate resource-collection-car@example.org => resource-car-audi-a4@example.org
itip_event = itip.events_from_message(message_from_string(itip_non_multipart))[0]
@@ -219,7 +216,7 @@ class TestWallaceResources(unittest.TestCase):
module_resources.send_response("resource-collection-car@example.org", itip_event)
- self.assertEqual(len(self.smtplog), 2);
+ self.assertEqual(len(self.smtplog), 2)
self.assertEqual("resource-collection-car@example.org", self.smtplog[0][0])
self.assertEqual("resource-car-audi-a4@example.org", self.smtplog[1][0])
@@ -235,5 +232,3 @@ class TestWallaceResources(unittest.TestCase):
self.assertIn("ACCEPTED".lower(), response2['subject'].lower(), "Delegation message subject: %r" % (response2['subject']))
self.assertEqual(ical2['attendee'].__str__(), "MAILTO:resource-car-audi-a4@example.org")
self.assertEqual(ical2['attendee'].params['PARTSTAT'], u"ACCEPTED")
-
-
diff --git a/tests/unit/test-012-wallace_invitationpolicy.py b/tests/unit/test-012-wallace_invitationpolicy.py
index 8250b89..2ed8709 100644
--- a/tests/unit/test-012-wallace_invitationpolicy.py
+++ b/tests/unit/test-012-wallace_invitationpolicy.py
@@ -69,6 +69,7 @@ conf = pykolab.getConf()
if not hasattr(conf, 'defaults'):
conf.finalize_conf()
+
class TestWallaceInvitationpolicy(unittest.TestCase):
def setUp(self):
@@ -86,7 +87,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.patch(smtplib.SMTP, "quit", self._mock_nop)
self.patch(smtplib.SMTP, "sendmail", self._mock_smtp_sendmail)
- self.smtplog = [];
+ self.smtplog = []
def _mock_find_user_dn(self, value, kolabuser=False):
(prefix, domain) = value.split('@')
@@ -94,7 +95,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
def _mock_get_entry_attributes(self, domain, entry, attributes):
(_, uid) = entry.split(',')[0].split('=')
- return { 'cn': uid, 'mail': uid + "@example.org", '_attrib': attributes }
+ return {'cn': uid, 'mail': uid + "@example.org", '_attrib': attributes}
def _mock_list_domains(self):
return {'example.org': 'example.org'}
@@ -121,19 +122,19 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual("uid=doe,ou=People,dc=example,dc=org", res)
def test_003_get_matching_invitation_policy(self):
- user = { 'kolabinvitationpolicy': [
+ user = {'kolabinvitationpolicy': [
'TASK_REJECT:*',
'EVENT_ACCEPT:example.org',
'EVENT_REJECT:gmail.com',
'ALL_UPDATE:outlook:com',
'ALL_MANUAL:*'
- ] }
+ ]}
self.assertEqual(MIP.get_matching_invitation_policies(user, 'a@fastmail.net', MIP.COND_TYPE_EVENT), [MIP.ACT_MANUAL])
self.assertEqual(MIP.get_matching_invitation_policies(user, 'b@example.org', MIP.COND_TYPE_EVENT), [MIP.ACT_ACCEPT, MIP.ACT_MANUAL])
self.assertEqual(MIP.get_matching_invitation_policies(user, 'c@gmail.com', MIP.COND_TYPE_EVENT), [MIP.ACT_REJECT, MIP.ACT_MANUAL])
self.assertEqual(MIP.get_matching_invitation_policies(user, 'd@somedomain.net', MIP.COND_TYPE_TASK), [MIP.ACT_REJECT, MIP.ACT_MANUAL])
- user = { 'kolabinvitationpolicy': ['ALL_SAVE_TO_FOLDER:maya.foo@example.org', 'ACT_REJECT:others'] }
+ user = {'kolabinvitationpolicy': ['ALL_SAVE_TO_FOLDER:maya.foo@example.org', 'ACT_REJECT:others']}
self.assertEqual(MIP.get_matching_invitation_policies(user, 'maya.foo@example.org', MIP.COND_TYPE_ALL), [MIP.ACT_SAVE_TO_FOLDER])
self.assertEqual(MIP.get_matching_invitation_policies(user, 'd@somedomain.net', MIP.COND_TYPE_ALL), [MIP.ACT_MANUAL])
@@ -152,27 +153,26 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
# self.assertFalse(os.path.isfile(lock_file))
def test_005_is_auto_reply(self):
- all_manual = [ 'ACT_MANUAL' ]
- accept_none = [ 'ACT_REJECT' ]
- accept_all = [ 'ACT_ACCEPT', 'ACT_UPDATE' ]
- accept_cond = [ 'ACT_ACCEPT_IF_NO_CONFLICT', 'ACT_REJECT_IF_CONFLICT' ]
- accept_some = [ 'ACT_ACCEPT_IF_NO_CONFLICT', 'ACT_SAVE_TO_CALENDAR:example.org', 'ACT_REJECT_IF_CONFLICT' ]
- accept_avail = [ 'ACT_ACCEPT_IF_NO_CONFLICT', 'ACT_REJECT_IF_CONFLICT:example.org' ]
-
- self.assertFalse( MIP.is_auto_reply({ 'kolabinvitationpolicy':all_manual }, 'user@domain.org', 'event'))
- self.assertTrue( MIP.is_auto_reply({ 'kolabinvitationpolicy':accept_none }, 'user@domain.org', 'event'))
- self.assertTrue( MIP.is_auto_reply({ 'kolabinvitationpolicy':accept_all }, 'user@domain.com', 'event'))
- self.assertTrue( MIP.is_auto_reply({ 'kolabinvitationpolicy':accept_cond }, 'user@domain.com', 'event'))
- self.assertTrue( MIP.is_auto_reply({ 'kolabinvitationpolicy':accept_some }, 'user@domain.com', 'event'))
- self.assertFalse( MIP.is_auto_reply({ 'kolabinvitationpolicy':accept_some }, 'sam@example.org', 'event'))
- self.assertFalse( MIP.is_auto_reply({ 'kolabinvitationpolicy':accept_avail }, 'user@domain.com', 'event'))
- self.assertTrue( MIP.is_auto_reply({ 'kolabinvitationpolicy':accept_avail }, 'john@example.org', 'event'))
+ all_manual = ['ACT_MANUAL']
+ accept_none = ['ACT_REJECT']
+ accept_all = ['ACT_ACCEPT', 'ACT_UPDATE']
+ accept_cond = ['ACT_ACCEPT_IF_NO_CONFLICT', 'ACT_REJECT_IF_CONFLICT']
+ accept_some = ['ACT_ACCEPT_IF_NO_CONFLICT', 'ACT_SAVE_TO_CALENDAR:example.org', 'ACT_REJECT_IF_CONFLICT']
+ accept_avail = ['ACT_ACCEPT_IF_NO_CONFLICT', 'ACT_REJECT_IF_CONFLICT:example.org']
+
+ self.assertFalse( MIP.is_auto_reply({'kolabinvitationpolicy': all_manual}, 'user@domain.org', 'event'))
+ self.assertTrue( MIP.is_auto_reply({'kolabinvitationpolicy': accept_none}, 'user@domain.org', 'event'))
+ self.assertTrue( MIP.is_auto_reply({'kolabinvitationpolicy': accept_all}, 'user@domain.com', 'event'))
+ self.assertTrue( MIP.is_auto_reply({'kolabinvitationpolicy': accept_cond}, 'user@domain.com', 'event'))
+ self.assertTrue( MIP.is_auto_reply({'kolabinvitationpolicy': accept_some}, 'user@domain.com', 'event'))
+ self.assertFalse( MIP.is_auto_reply({'kolabinvitationpolicy': accept_some}, 'sam@example.org', 'event'))
+ self.assertFalse( MIP.is_auto_reply({'kolabinvitationpolicy': accept_avail}, 'user@domain.com', 'event'))
+ self.assertTrue( MIP.is_auto_reply({'kolabinvitationpolicy': accept_avail}, 'john@example.org', 'event'))
def test_006_send_update_notification(self):
itips = pykolab.itip.events_from_message(message_from_string(itip_multipart.replace('SUMMARY:test', 'SUMMARY:with äöü')))
- MIP.send_update_notification(itips[0]['xml'], { 'mail': 'sender@example.org' }, old=None, reply=True)
+ MIP.send_update_notification(itips[0]['xml'], {'mail': 'sender@example.org'}, old=None, reply=True)
self.assertEqual(len(self.smtplog), 1)
self.assertIn("Subject: =?utf-8?", self.smtplog[0][2])
self.assertIn("The event 'with =C3=A4=C3=B6=C3=BC' at", self.smtplog[0][2])
-
diff --git a/tests/unit/test-014-conf-and-raw.py b/tests/unit/test-014-conf-and-raw.py
index 677cb2f..e7f0ba6 100644
--- a/tests/unit/test-014-conf-and-raw.py
+++ b/tests/unit/test-014-conf-and-raw.py
@@ -8,6 +8,7 @@ import unittest
conf = pykolab.getConf()
conf.finalize_conf(fatal=False)
+
class TestConfRaw(unittest.TestCase):
config_file = None
@@ -25,7 +26,7 @@ class TestConfRaw(unittest.TestCase):
def test_001_set(self):
password = '$%something'
conf.command_set('kolab', 'test_password', password)
-
+
def test_002_get(self):
password = conf.get('kolab', 'test_password')
self.assertEqual('$%something', password)
diff --git a/tests/unit/test-015-translate.py b/tests/unit/test-015-translate.py
index e9d3bdd..513bcfc 100644
--- a/tests/unit/test-015-translate.py
+++ b/tests/unit/test-015-translate.py
@@ -4,6 +4,7 @@ import unittest
import gettext
from pykolab import translate
+
class TestTranslate(unittest.TestCase):
def test_001_default_langs(self):
diff --git a/tests/unit/test-016-todo.py b/tests/unit/test-016-todo.py
index b94d12d..4760399 100644
--- a/tests/unit/test-016-todo.py
+++ b/tests/unit/test-016-todo.py
@@ -188,6 +188,7 @@ Due Time: 13:30 AM</text>
</icalendar>
"""
+
class TestTodoXML(unittest.TestCase):
todo = Todo()
@@ -198,7 +199,7 @@ class TestTodoXML(unittest.TestCase):
if (type(_value)) == _type:
return True
else:
- raise AssertionError, "%s != %s" % (type(_value), _type)
+ raise AssertionError("%s != %s" % (type(_value), _type))
def test_001_minimal(self):
self.todo.set_summary("test")
@@ -227,7 +228,6 @@ class TestTodoXML(unittest.TestCase):
self.assertEqual(todo.get_status(True), "IN-PROCESS")
self.assertEqual(todo.get_related_to(), "9F3E68BED4A94DA2A51EE589F7FDC6C8-A4BF5BBB9FEAA271")
-
def test_020_load_from_ical(self):
ical_str = """BEGIN:VCALENDAR
VERSION:2.0
@@ -239,12 +239,12 @@ METHOD:REQUEST
ical = icalendar.Calendar.from_ical(ical_str)
vtodo = ical.walk('VTODO')[0]
- #print vtodo
+ # print vtodo
todo = todo_from_ical(ical.walk('VTODO')[0].to_ical())
self.assertEqual(todo.get_summary(), "Sample Task assignment")
self.assertIsInstance(todo.get_start(), datetime.datetime)
self.assertEqual(todo.get_percentcomplete(), 20)
- #print str(todo)
+ # print str(todo)
data = todo.to_dict()
self.assertIsInstance(data['rrule'], dict)
@@ -271,7 +271,6 @@ METHOD:REQUEST
self.assertIsInstance(vtodo['due'].dt, datetime.datetime)
self.assertIsInstance(vtodo['dtstamp'].dt, datetime.datetime)
-
def test_022_ical_with_attachment(self):
todo = todo_from_ical(ical_todo_attachment)
@@ -299,6 +298,5 @@ METHOD:REQUEST
self.assertEqual(len(data['alarm']), 1)
self.assertEqual(data['alarm'][0]['action'], 'DISPLAY')
-
if __name__ == '__main__':
- unittest.main() \ No newline at end of file
+ unittest.main()
diff --git a/tests/unit/test-017-diff.py b/tests/unit/test-017-diff.py
index 4b0c72c..46e0a77 100644
--- a/tests/unit/test-017-diff.py
+++ b/tests/unit/test-017-diff.py
@@ -140,8 +140,9 @@ xml_todo_02 = """<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
</icalendar>
"""
+
class TestComputeDiff(unittest.TestCase):
-
+
def test_000_order_proplists(self):
one = {
"uri": "cid:one",
@@ -202,6 +203,5 @@ class TestComputeDiff(unittest.TestCase):
self.assertEqual(diff[4]['property'], 'lastmodified-date')
-
if __name__ == '__main__':
- unittest.main() \ No newline at end of file
+ unittest.main()
diff --git a/tests/unit/test-018-note.py b/tests/unit/test-018-note.py
index dca077f..7a7bddf 100644
--- a/tests/unit/test-018-note.py
+++ b/tests/unit/test-018-note.py
@@ -25,7 +25,9 @@ xml_note = """
</note>
"""
+
class TestNoteXML(unittest.TestCase):
+
def assertIsInstance(self, _value, _type):
if hasattr(unittest.TestCase, 'assertIsInstance'):
return unittest.TestCase.assertIsInstance(self, _value, _type)
@@ -33,7 +35,7 @@ class TestNoteXML(unittest.TestCase):
if (type(_value)) == _type:
return True
else:
- raise AssertionError, "%s != %s" % (type(_value), _type)
+ raise AssertionError("%s != %s" % (type(_value), _type))
def test_001_minimal(self):
note = Note()
@@ -82,7 +84,7 @@ class TestNoteXML(unittest.TestCase):
data = note_from_string(xml_note).to_dict()
self.assertIsInstance(data, dict)
- self.assertTrue(data.has_key('uid'))
+ self.assertTrue('uid' in data)
self.assertIsInstance(data.get('created', None), datetime.datetime)
self.assertIsInstance(data.get('lastmodified-date', None), datetime.datetime)
self.assertEqual(data.get('summary', None), "Kolab Note")
@@ -91,6 +93,5 @@ class TestNoteXML(unittest.TestCase):
self.assertEqual(len(data.get('categories', None)), 2)
self.assertTrue('<p>This is a HTML note</p>' in data.get('description', None))
-
if __name__ == '__main__':
unittest.main()
diff --git a/tests/unit/test-019-contact.py b/tests/unit/test-019-contact.py
index d5366f6..6446ad9 100644
--- a/tests/unit/test-019-contact.py
+++ b/tests/unit/test-019-contact.py
@@ -280,6 +280,7 @@ Content-Disposition: attachment;
--=_4ff5155d75dc1328b7f5fe10ddce8d24--
"""
+
class TestContactXML(unittest.TestCase):
contact = Contact()
@@ -290,7 +291,7 @@ class TestContactXML(unittest.TestCase):
if (type(_value)) == _type:
return True
else:
- raise AssertionError, "%s != %s" % (type(_value), _type)
+ raise AssertionError("%s != %s" % (type(_value), _type))
def test_001_minimal(self):
self.contact.set_name("test")
@@ -346,6 +347,5 @@ class TestContactXML(unittest.TestCase):
self.assertIsInstance(data['photo'], dict)
self.assertEqual(data['photo']['mimetype'], 'image/gif')
-
if __name__ == '__main__':
- unittest.main() \ No newline at end of file
+ unittest.main()
diff --git a/tests/unit/test-020-auth_cache.py b/tests/unit/test-020-auth_cache.py
index c4740dc..d30d403 100644
--- a/tests/unit/test-020-auth_cache.py
+++ b/tests/unit/test-020-auth_cache.py
@@ -37,12 +37,9 @@ except:
metadata = MetaData()
-##
-## Classes
-##
-
DeclarativeBase = declarative_base()
+
class Entry(DeclarativeBase):
__tablename__ = 'entries'
@@ -67,6 +64,7 @@ db = Session()
auth_cache.db = db
+
class TestAuthCache(unittest.TestCase):
def test_001_plain_insert(self):
auth_cache.set_entry(
diff --git a/ucs/kolab_sieve.py b/ucs/kolab_sieve.py
index 1f78bf5..d7125a7 100755
--- a/ucs/kolab_sieve.py
+++ b/ucs/kolab_sieve.py
@@ -36,7 +36,7 @@ sys.path = [
),
'..'
)
- ) ] + sys.path
+ )] + sys.path
sys.stderr = open('/dev/null', 'a')
@@ -63,6 +63,7 @@ conf.debuglevel = 9
from pykolab.auth import Auth
+
def handler(*args, **kw):
auth = Auth()
auth.connect()
@@ -84,7 +85,7 @@ def handler(*args, **kw):
result_attr = conf.get('cyrus-sasl', 'result_attribute')
- if not new.has_key(result_attr):
+ if result_attr not in new:
log.error(
"Entry %r does not have attribute %r" % (
dn,
@@ -97,13 +98,13 @@ def handler(*args, **kw):
# See if the mailserver_attribute exists
mailserver_attribute = conf.get('ldap', 'mailserver_attribute').lower()
- if mailserver_attribute == None:
+ if mailserver_attribute is None:
log.error("Mail server attribute is not set")
# TODO: Perhaps, query for IMAP servers. If there is only one,
# we know what to do.
return
- if new.has_key(mailserver_attribute):
+ if mailserver_attribute in new:
if not new[mailserver_attribute] == constants.fqdn:
log.info(
"The mail server for user %r is set, and it is not me (%r)" % (
@@ -119,9 +120,7 @@ def handler(*args, **kw):
conf.plugins.exec_hook(
'sieve_mgmt_refresh',
- kw = {
- 'user': new[result_attr]
- }
+ kw={'user': new[result_attr]}
)
else:
@@ -136,24 +135,21 @@ def handler(*args, **kw):
mailserver_attribute = conf.get('ldap', 'mailserver_attribute').lower()
result_attr = conf.get('cyrus-sasl', 'result_attribute').lower()
- if mailserver_attribute == None:
+ if mailserver_attribute is None:
log.error("Mail server attribute is not set")
# TODO: Perhaps, query for IMAP servers. If there is only one,
# we know what to do.
return
- if new.has_key(mailserver_attribute):
+ if mailserver_attribute in new:
if not new[mailserver_attribute] == constants.fqdn:
log.info("The mail server for user %r is set, and it is not me (%r)" % (dn, new[mailserver_attribute]))
return
conf.plugins.exec_hook(
'sieve_mgmt_refresh',
- kw = {
- 'user': new[result_attr]
- }
+ kw={'user': new[result_attr]}
)
else:
log.info("entry %r changed, but no new or old attributes" % (dn))
-
diff --git a/ucs/listener.py b/ucs/listener.py
index be7b9e9..67c3dca 100755
--- a/ucs/listener.py
+++ b/ucs/listener.py
@@ -36,7 +36,7 @@ sys.path = [
),
'..'
)
- ) ] + sys.path
+ )] + sys.path
#sys.stderr = open('/dev/null', 'a')
@@ -46,14 +46,14 @@ description = "Kolab Groupware Listener for UCS"
# The filter has to be composed to make sure only Kolab Groupware
# related objects are passed along to this listener module.
filter = '(|(objectClass=kolabInetOrgPerson)(objectClass=univentionMailSharedFolder))'
-#attributes = [ '*' ]
+# attributes = ['*']
import pykolab
from pykolab import constants
from pykolab import utils
log = pykolab.getLogger('pykolab.listener')
-#log.remove_stdout_handler()
+# log.remove_stdout_handler()
log.setLevel(logging.DEBUG)
log.debuglevel = 9
@@ -63,6 +63,7 @@ conf.debuglevel = 9
from pykolab.auth import Auth
+
def handler(*args, **kw):
log.info("kolab.handler(args(%d): %r, kw: %r)" % (len(args), args, kw))
@@ -93,11 +94,11 @@ def handler(*args, **kw):
mailserver_attribute = conf.get('ldap', 'mailserver_attribute').lower()
- if mailserver_attribute == None:
+ if mailserver_attribute is None:
log.error("Mail server attribute is not set")
return
- if old.has_key(mailserver_attribute):
+ if mailserver_attribute in old:
log.info("Modified entry %r has mail server attribute %s: %r" % (dn, mailserver_attribute, new[mailserver_attribute]))
if not old[mailserver_attribute] == constants.fqdn:
@@ -109,7 +110,7 @@ def handler(*args, **kw):
else:
# If old has no mailserver attribute, but new does, we need to create
# the user locally.
- if new.has_key(mailserver_attribute):
+ if mailserver_attribute in new:
if not new[mailserver_attribute] == constants.fqdn:
log.info("The mail server for user %r is set (in new, not old), but it is not me (%r)" % (dn, new[mailserver_attribute]))
return
@@ -118,11 +119,11 @@ def handler(*args, **kw):
return
auth._auth._synchronize_callback(
- change_type = 'modify',
- previous_dn = None,
- change_number = None,
- dn = dn,
- entry = new
+ change_type='modify',
+ previous_dn=None,
+ change_number=None,
+ dn=dn,
+ entry=new
)
else:
@@ -131,13 +132,13 @@ def handler(*args, **kw):
# See if the mailserver_attribute exists
mailserver_attribute = conf.get('ldap', 'mailserver_attribute').lower()
- if mailserver_attribute == None:
+ if mailserver_attribute is None:
log.error("Mail server attribute is not set")
# TODO: Perhaps, query for IMAP servers. If there is only one,
# we know what to do.
return
- if old.has_key(mailserver_attribute):
+ if mailserver_attribute in old:
log.info("Deleted entry %r has mail server attribute %s: %r" % (dn, mailserver_attribute, old[mailserver_attribute]))
if not old[mailserver_attribute] == constants.fqdn:
@@ -152,11 +153,11 @@ def handler(*args, **kw):
if cfg.is_true('mail/cyrus/mailbox/delete', True):
auth._auth._synchronize_callback(
- change_type = 'delete',
- previous_dn = None,
- change_number = None,
- dn = dn,
- entry = old
+ change_type='delete',
+ previous_dn=None,
+ change_number=None,
+ dn=dn,
+ entry=old
)
elif isinstance(new, dict) and len(new.keys()) > 0:
@@ -166,13 +167,13 @@ def handler(*args, **kw):
# See if the mailserver_attribute exists
mailserver_attribute = conf.get('ldap', 'mailserver_attribute').lower()
- if mailserver_attribute == None:
+ if mailserver_attribute is None:
log.error("Mail server attribute is not set")
# TODO: Perhaps, query for IMAP servers. If there is only one,
# we know what to do.
return
- if new.has_key(mailserver_attribute):
+ if mailserver_attribute in new:
log.info("Added entry %r has mail server attribute %s: %r" % (dn, mailserver_attribute, new[mailserver_attribute]))
if not new[mailserver_attribute] == constants.fqdn:
@@ -184,15 +185,16 @@ def handler(*args, **kw):
return
auth._auth._synchronize_callback(
- change_type = 'add',
- previous_dn = None,
- change_number = None,
- dn = dn,
- entry = new
+ change_type='add',
+ previous_dn=None,
+ change_number=None,
+ dn=dn,
+ entry=new
)
else:
log.info("entry %r changed, but no new or old attributes" % (dn))
+
def initialize():
log.info("kolab.initialize()")
diff --git a/wallace.py b/wallace.py
index 9371823..a45f34a 100755
--- a/wallace.py
+++ b/wallace.py
@@ -37,4 +37,3 @@ import wallace
if __name__ == "__main__":
wallace = wallace.WallaceDaemon()
wallace.run()
-