summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-23 13:38:40 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-23 13:38:40 +0100
commit8dbdba5cc919cefc5b4ab12f2b2cfeb14b2c4ae1 (patch)
tree093253e4a05c67da6671ec6f373e2baa8f30d9bf /tests
parent90785cfbce1a9cd0f773b0ad28592fb1537e2a69 (diff)
downloadpykolab-8dbdba5cc919cefc5b4ab12f2b2cfeb14b2c4ae1.tar.gz
Begin work on a set of unittests
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py4
-rw-r--r--tests/test-000.py23
-rw-r--r--tests/test-001.py18
-rw-r--r--tests/test-002.py70
4 files changed, 115 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..b5e7094
--- /dev/null
+++ b/tests/__init__.py
@@ -0,0 +1,4 @@
+import sys
+
+sys.path = [ '.', '..' ] + sys.path
+
diff --git a/tests/test-000.py b/tests/test-000.py
new file mode 100644
index 0000000..17e1c57
--- /dev/null
+++ b/tests/test-000.py
@@ -0,0 +1,23 @@
+import unittest
+
+class TestImports(unittest.TestCase):
+ def test_pykolab(self):
+ import pykolab
+
+ def test_pykolab_xml(self):
+ import pykolab.xml
+
+ def test_pykolab_xml_attendee(self):
+ from pykolab.xml import Attendee
+
+ def test_pykolab_xml_contact(self):
+ from pykolab.xml import Contact
+
+ def test_pykolab_xml_contactReference(self):
+ from pykolab.xml import ContactReference
+
+ def test_pykolab_xml_event(self):
+ from pykolab.xml import Event
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/test-001.py b/tests/test-001.py
new file mode 100644
index 0000000..83f1c33
--- /dev/null
+++ b/tests/test-001.py
@@ -0,0 +1,18 @@
+import datetime
+import unittest
+
+from pykolab.xml import Attendee
+
+class TestEventXML(unittest.TestCase):
+ attendee = Attendee("jane@doe.org")
+
+ def test_001_minimal(self):
+ self.assertIsInstance(self.attendee.__str__(), basestring)
+
+ def test_002_set_name(self):
+ name = "Doe, Jane"
+ self.attendee.set_name(name)
+ self.assertEqual(self.attendee.get_name(), name)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/test-002.py b/tests/test-002.py
new file mode 100644
index 0000000..3a6a863
--- /dev/null
+++ b/tests/test-002.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()