tests/functional wallace/module_resources.py

Thomas Brüderli bruederli at kolabsys.com
Tue Feb 25 19:03:11 CET 2014


 tests/functional/test_wallace/test_005_resource_invitation.py |   32 ++++++++++
 wallace/module_resources.py                                   |    2 
 2 files changed, 32 insertions(+), 2 deletions(-)

New commits:
commit 054161ee8b09c58719e02f2189e8ac5112860751
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Wed Feb 19 18:30:31 2014 -0500

    Verify reservation event is present in resource calendar

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']:




More information about the commits mailing list