summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-08-07 07:36:03 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-08-07 07:36:35 (GMT)
commit8f38b9049400ab9d65e39e7b1e389a0aee5ec3f5 (patch)
tree58dd31921bda8e48a0c3960be0cbfbd3b77bb419
parentc860449b6b1c1f7e29cacf32997f67d1acf5d3e1 (diff)
downloadlibkolabxml-8f38b9049400ab9d65e39e7b1e389a0aee5ec3f5.tar.gz
Turn test.py into a real unittest case. Add tests for Attendee.delegatedTo() and delegatedFrom() getters.
-rw-r--r--src/python/test.py69
1 files changed, 54 insertions, 15 deletions
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@doe.org"))
+ att1.setRole(kolabformat.NonParticipant)
+ att1.setPartStat(kolabformat.PartDelegated)
+ att1.setDelegatedTo([kolabformat.ContactReference("jane@doe.org")])
+
+ att2 = kolabformat.Attendee(kolabformat.ContactReference("jane@doe.org"))
+ att2.setRole(kolabformat.Required)
+ att2.setPartStat(kolabformat.PartNeedsAction)
+ att2.setDelegatedFrom([kolabformat.ContactReference("john@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