def test_retrieve_headers_for_messages(self): coll = MessageDataHandler() notification = { 'uri': 'imap://[email protected]@kolab.example.org/Calendar', 'uidset': '3' } notification = json.loads(coll.retrieve_headers_for_messages(json.dumps(notification))) self.assertTrue(notification.has_key('messageHeaders')) self.assertIsInstance(notification['messageHeaders'], dict) self.assertTrue(notification['messageHeaders'].has_key('3')) headers = notification['messageHeaders']['3'] self.assertIsInstance(headers, dict) self.assertEqual(headers['Subject'], 'Test') self.assertEqual(headers['From'][0], 'John Doe <*****@*****.**>')
def test_retrieve_contents_for_messages(self): coll = MessageDataHandler() notification = { 'uri': 'imap://[email protected]@kolab.example.org/Calendar', 'uidset': '3' } notification = json.loads(coll.retrieve_contents_for_messages(json.dumps(notification))) self.assertTrue(notification.has_key('messageContent')) self.assertIsInstance(notification['messageContent'], dict) self.assertTrue(notification['messageContent'].has_key('3')) self.assertIsInstance(notification['messageContent']['3'], unicode) self.assertTrue(notification.has_key('messageHeaders')) self.assertIsInstance(notification['messageHeaders'], dict) self.assertTrue(notification['messageHeaders'].has_key('3')) self.assertIsInstance(notification['messageHeaders']['3'], dict)