summaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2016-05-04 15:53:48 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2016-05-04 15:53:48 +0200
commitc204eaaa2c9a006432fe00489a352833143db01d (patch)
tree18860f2e335b9a98d34f404d5c4b81d22f2ce222 /tests/unit
parent4a24e0cc403321713ee1201ade9d36956da1c060 (diff)
downloadpykolab-c204eaaa2c9a006432fe00489a352833143db01d.tar.gz
CS fixes according to PEP8 (ignored mostly line-length errors only)
Summary: . Reviewers: #pykolab_developers Differential Revision: https://git.kolab.org/D134
Diffstat (limited to 'tests/unit')
-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
21 files changed, 186 insertions, 194 deletions
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(