summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-02-19 18:30:31 -0500
committerThomas Bruederli <bruederli@kolabsys.com>2014-02-19 18:30:31 -0500
commit054161ee8b09c58719e02f2189e8ac5112860751 (patch)
treebd9058f18d5782c43db0f7275e8b1f3252023fb1
parent66baddf10c099c8b0c287c267e58afeec387d520 (diff)
downloadpykolab-054161ee8b09c58719e02f2189e8ac5112860751.tar.gz
Verify reservation event is present in resource calendar
-rw-r--r--tests/functional/test_wallace/test_005_resource_invitation.py32
-rw-r--r--wallace/module_resources.py2
2 files changed, 32 insertions, 2 deletions
diff --git a/tests/functional/test_wallace/test_005_resource_invitation.py b/tests/functional/test_wallace/test_005_resource_invitation.py
index 4b6900e..085ad3b 100644
--- a/tests/functional/test_wallace/test_005_resource_invitation.py
+++ b/tests/functional/test_wallace/test_005_resource_invitation.py
@@ -124,6 +124,35 @@ class TestResourceInvitation(unittest.TestCase):
time.sleep(1)
+ imap.disconnect()
+
+ return found
+
+ def check_resource_calendar_event(self, mailbox, uid=None):
+ imap = IMAP()
+ imap.connect()
+
+ imap.imap.m.select(u'"'+mailbox+'"')
+ typ, data = imap.imap.m.search(None, '(UNDELETED HEADER SUBJECT "%s")' % (uid) if uid else '(UNDELETED HEADER X-Kolab-Type "application/x-vnd.kolab.event")')
+
+ found = None
+
+ for num in data[0].split():
+ typ, data = imap.imap.m.fetch(num, '(RFC822)')
+ event_message = message_from_string(data[0][1])
+
+ for part in event_message.walk():
+ # return matching UID or first event found
+ if (not uid or event_message['subject'] == uid) and part.get_content_type() == "application/calendar+xml":
+ payload = part.get_payload(decode=True)
+ found = pykolab.xml.event_from_string(payload)
+ break
+
+ if found:
+ break
+
+ imap.disconnect()
+
return found
@@ -143,3 +172,6 @@ class TestResourceInvitation(unittest.TestCase):
response = self.check_message_received("Meeting Request ACCEPTED")
self.assertIsInstance(response, email.message.Message)
+ event = self.check_resource_calendar_event(self.audi['kolabtargetfolder'], '626421779C777FBE9C9B85A80D04DDFA-A4BF5BBB9FEAA271')
+ self.assertIsInstance(event, pykolab.xml.Event)
+ self.assertEqual(event.get_summary(), "test")
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index 0dfe1df..e76df24 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -334,8 +334,6 @@ def read_resource_calendar(resource_rec, itip_events, imap):
imap.imap.m.select(mailbox)
typ, data = imap.imap.m.search(None, 'ALL')
- num_messages = len(data[0].split())
-
for num in data[0].split():
# For efficiency, makes the routine non-deterministic
if resource_rec['conflict']: