summaryrefslogtreecommitdiffstats
path: root/tests/test-003-event.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-003-event.py')
-rw-r--r--tests/test-003-event.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/test-003-event.py b/tests/test-003-event.py
new file mode 100644
index 0000000..3a6a863
--- /dev/null
+++ b/tests/test-003-event.py
@@ -0,0 +1,70 @@
+import datetime
+import unittest
+
+from pykolab.xml import Attendee
+from pykolab.xml import Event
+from pykolab.xml import EventIntegrityError
+from pykolab.xml import InvalidAttendeeParticipantStatusError
+from pykolab.xml import InvalidEventDateError
+
+class TestEventXML(unittest.TestCase):
+ event = Event()
+
+ def test_000_no_start_date(self):
+ self.assertRaises(EventIntegrityError, self.event.__str__)
+
+ def test_001_minimal(self):
+ self.event.set_start(datetime.datetime.now())
+ self.assertIsInstance(self.event.get_start(), datetime.datetime)
+ self.assertIsInstance(self.event.__str__(), basestring)
+
+ def test_002_attendees_list(self):
+ self.assertIsInstance(self.event.get_attendees(), list)
+
+ def test_003_attendees_no_default(self):
+ self.assertEqual(len(self.event.get_attendees()), 0)
+
+ def test_004_attendee_add(self):
+ self.event.add_attendee("john@doe.org")
+ self.assertIsInstance(self.event.get_attendees(), list)
+ self.assertEqual(len(self.event.get_attendees()), 1)
+
+ def test_005_attendee_add_name(self):
+ self.event.add_attendee("jane@doe.org", "Doe, Jane")
+ self.assertIsInstance(self.event.get_attendees(), list)
+ self.assertEqual(len(self.event.get_attendees()), 2)
+
+ def test_006_get_attendees(self):
+ self.assertEqual([x.get_email() for x in self.event.get_attendees()], ["john@doe.org", "jane@doe.org"])
+
+ def test_007_get_attendee_by_email(self):
+ attendee = self.event.get_attendee_by_email("jane@doe.org")
+ self.assertIsInstance(attendee, Attendee)
+
+ attendee = self.event.get_attendee("jane@doe.org")
+ self.assertIsInstance(attendee, Attendee)
+
+ self.assertRaises(ValueError, self.event.get_attendee_by_email, "nosuchattendee@invalid.domain")
+ self.assertRaises(ValueError, self.event.get_attendee, "nosuchattendee@invalid.domain")
+
+ def test_008_get_attendee_by_name(self):
+ attendee = self.event.get_attendee_by_name("Doe, Jane")
+ self.assertIsInstance(attendee, Attendee)
+
+ attendee = self.event.get_attendee("Doe, Jane")
+ self.assertIsInstance(attendee, Attendee)
+
+ self.assertRaises(ValueError, self.event.get_attendee_by_name, "Houdini, Harry")
+ self.assertRaises(ValueError, self.event.get_attendee, "Houdini, Harry")
+
+ def test_009_invalid_participant_status(self):
+ self.assertRaises(InvalidAttendeeParticipantStatusError, self.event.set_attendee_participant_status, "jane@doe.org", "INVALID")
+
+ def test_010_datetime_from_string(self):
+ self.assertRaises(InvalidEventDateError, self.event.set_start, "2012-05-23 11:58:00")
+
+ def test_011_attendee_equality(self):
+ self.assertEqual(self.event.get_attendee("jane@doe.org").get_email(), "jane@doe.org")
+
+if __name__ == '__main__':
+ unittest.main()