src/python

Thomas Brüderli bruederli at kolabsys.com
Thu Aug 7 09:37:13 CEST 2014


 src/python/test.py |   69 +++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 54 insertions(+), 15 deletions(-)

New commits:
commit 8f38b9049400ab9d65e39e7b1e389a0aee5ec3f5
Author: Thomas Bruederli <thomas at roundcube.net>
Date:   Thu Aug 7 09:36:03 2014 +0200

    Turn test.py into a real unittest case. Add tests for Attendee.delegatedTo() and delegatedFrom() getters.

diff --git a/src/python/test.py b/src/python/test.py
index f7a306e..1fae8bb 100644
--- a/src/python/test.py
+++ b/src/python/test.py
@@ -1,16 +1,55 @@
 import kolabformat
-e = kolabformat.Event()
-
-ex = e.exceptionDates()
-ex.size()
-ex.push_back(kolabformat.cDateTime(1,1,1))
-ex.size()
-e.exceptionDates().size()
-e.setExceptionDates(ex)
-e.exceptionDates().size()
-
-string = kolabformat.writeEvent(e);
-print string;
-e1 = kolabformat.readEvent(string, False);
-string = kolabformat.writeEvent(e1);
-print string;
\ No newline at end of file
+import unittest
+
+class TestKolabformat(unittest.TestCase):
+
+    def test_event_basic(self):
+        e = kolabformat.Event()
+        e.setSummary("test")
+
+        start = kolabformat.cDateTime(2014,7,1, 12,30,0)
+        start.setTimezone("Europe/London")
+        e.setStart(start)
+
+        ex = e.exceptionDates()
+        ex.size()
+        ex.push_back(kolabformat.cDateTime(2014,7,5))
+        ex.size()
+        e.exceptionDates().size()
+        e.setExceptionDates(ex)
+        e.exceptionDates().size()
+
+        xml = kolabformat.writeEvent(e)
+        e1 = kolabformat.readEvent(xml, False)
+        xml1 = kolabformat.writeEvent(e1)
+        self.assertEqual(xml, xml1)
+
+    def test_event_delegated(self):
+        e = kolabformat.Event()
+        e.setSummary("test")
+        e.setStart(kolabformat.cDateTime(2014,7,1, 12,30,0))
+
+        att1 = kolabformat.Attendee(kolabformat.ContactReference("john at doe.org"))
+        att1.setRole(kolabformat.NonParticipant)
+        att1.setPartStat(kolabformat.PartDelegated)
+        att1.setDelegatedTo([kolabformat.ContactReference("jane at doe.org")])
+
+        att2 = kolabformat.Attendee(kolabformat.ContactReference("jane at doe.org"))
+        att2.setRole(kolabformat.Required)
+        att2.setPartStat(kolabformat.PartNeedsAction)
+        att2.setDelegatedFrom([kolabformat.ContactReference("john at doe.org")])
+
+        e.setAttendees([att1, att2])
+        self.assertEqual(len(att1.delegatedTo()), 1)
+        self.assertEqual(len(att2.delegatedFrom()), 1)
+
+        xml = kolabformat.writeEvent(e)
+        e1 = kolabformat.readEvent(xml, False)
+        print xml
+
+        self.assertEqual(len(e1.attendees()[0].delegatedTo()), 1)
+        self.assertEqual(len(e1.attendees()[0].delegatedFrom()), 1)
+
+
+if __name__ == '__main__':
+    unittest.main()
\ No newline at end of file




More information about the commits mailing list