summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-03-02 10:01:21 -0500
committerThomas Bruederli <bruederli@kolabsys.com>2015-03-02 10:01:21 -0500
commit3cc3391170e54fb3e4bf477562bc2ef4bf8885c3 (patch)
tree4a182e5b16dbab0c4b37202813fc718bf7fdcafd /tests
parentdaaa39a33e05934462b42d650873a4453c6fd5ca (diff)
downloadpykolab-3cc3391170e54fb3e4bf477562bc2ef4bf8885c3.tar.gz
Store invitations to single occurrences with the same UID in one object (#4726)
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/test_wallace/test_007_invitationpolicy.py42
-rw-r--r--tests/unit/test-003-event.py38
2 files changed, 77 insertions, 3 deletions
diff --git a/tests/functional/test_wallace/test_007_invitationpolicy.py b/tests/functional/test_wallace/test_007_invitationpolicy.py
index cc99c73..a019949 100644
--- a/tests/functional/test_wallace/test_007_invitationpolicy.py
+++ b/tests/functional/test_wallace/test_007_invitationpolicy.py
@@ -351,11 +351,13 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
smtp = smtplib.SMTP('localhost', 10026)
smtp.sendmail(from_addr, to_addr, mime_message % (to_addr, method, itip_payload))
- def send_itip_invitation(self, attendee_email, start=None, allday=False, template=None, summary="test", sequence=0, partstat='NEEDS-ACTION', from_addr=None, instance=None):
+ def send_itip_invitation(self, attendee_email, start=None, allday=False, template=None, summary="test", sequence=0, partstat='NEEDS-ACTION', from_addr=None, uid=None, instance=None):
if start is None:
start = datetime.datetime.now()
- uid = str(uuid.uuid4())
+ if uid is None:
+ uid = str(uuid.uuid4())
+
recurrence_id = ''
if allday:
@@ -1235,9 +1237,12 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
start = datetime.datetime(2015,5,4, 6,30,0)
uid = self.send_itip_invitation(self.mark['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.mark['mail'])
+ 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'])
self.assertIsInstance(response, email.message.Message)
+ pykolab.translate.setUserLanguage(conf.get('kolab','default_locale'))
+
event = self.check_user_calendar_event(self.mark['kolabcalendarfolder'], uid)
self.assertIsInstance(event, pykolab.xml.Event)
@@ -1267,6 +1272,37 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertIsInstance(event, pykolab.xml.Event)
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"))
+ 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'])
+ self.assertIsInstance(response, email.message.Message)
+ self.assertIn("RECURRENCE-ID", str(response))
+
+ event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid)
+ self.assertIsInstance(event, pykolab.xml.Event)
+ self.assertEqual(len(event.get_exceptions()), 1)
+
+ exception = event.get_instance(newstart)
+ self.assertEqual(exception.get_summary(), "single #2")
+ self.assertEqual(exception.get_recurrence_id(), newstart)
+
+ # send an update occurrence #1
+ self.send_itip_invitation(self.jane['mail'], summary="updated #1", uid=uid, start=start, instance=start)
+ time.sleep(5)
+
+ # send an update occurrence #2
+ self.send_itip_invitation(self.jane['mail'], summary="updated #2", uid=uid, start=newstart, instance=newstart)
+
+ time.sleep(10)
+ event = self.check_user_calendar_event(self.jane['kolabcalendarfolder'], uid)
+ self.assertIsInstance(event, pykolab.xml.Event)
+ self.assertEqual(event.get_summary(), "updated #1")
+
+ 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)
diff --git a/tests/unit/test-003-event.py b/tests/unit/test-003-event.py
index 1f9f36b..5798101 100644
--- a/tests/unit/test-003-event.py
+++ b/tests/unit/test-003-event.py
@@ -744,6 +744,44 @@ END:VEVENT
self.assertIsInstance(exception['recurrence-id'].dt, datetime.datetime)
self.assertEqual(exception['recurrence-id'].params.get('RANGE'), None)
+ def test_021_single_instances(self):
+ self.event = Event()
+ self.event.set_summary('singles')
+
+ _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"))
+ xmlexception = Event(from_string=str(self.event))
+ xmlexception.set_start(_start2)
+ xmlexception.set_end(_start2 + datetime.timedelta(hours=1))
+ xmlexception.set_summary('singles #2')
+ xmlexception.set_recurrence_id(_start2)
+ self.event.add_exception(xmlexception)
+
+ self.assertEqual(self.event.has_exceptions(), True)
+
+ first = self.event.get_instance(_start)
+ self.assertIsInstance(first, Event)
+ self.assertEqual(first.get_summary(), "singles")
+
+ second = self.event.get_instance(_start2)
+ self.assertIsInstance(second, Event)
+ self.assertEqual(second.get_summary(), "singles #2")
+
+ # update main instance
+ first.set_status('CANCELLED')
+ first.set_summary("singles #1")
+ self.event.add_exception(first)
+
+ event = event_from_string(str(self.event))
+ self.assertEqual(self.event.has_exceptions(), True)
+ 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')