summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-24 12:15:13 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-24 12:15:13 +0100
commit0a287401ae7a29a9e30696f4774f160ca751a34d (patch)
treebadebf35762e66cdbe782a9c2503687360270950 /tests
parentc8b897e57342e565c7f01fcbffc470c14fab73f6 (diff)
downloadpykolab-0a287401ae7a29a9e30696f4774f160ca751a34d.tar.gz
Extend tests to 43 in total (attendee, event)
Diffstat (limited to 'tests')
-rw-r--r--tests/test-002-attendee.py75
-rw-r--r--tests/test-003-event.py27
2 files changed, 92 insertions, 10 deletions
diff --git a/tests/test-002-attendee.py b/tests/test-002-attendee.py
index 74f680b..15ce83f 100644
--- a/tests/test-002-attendee.py
+++ b/tests/test-002-attendee.py
@@ -17,5 +17,80 @@ class TestEventXML(unittest.TestCase):
self.attendee.set_name(name)
self.assertEqual(self.attendee.get_name(), name)
+ def test_004_default_participant_status(self):
+ self.assertEqual(self.attendee.get_participant_status(), 0)
+
+ def test_005_participant_status_map_length(self):
+ self.assertEqual(len(self.attendee.participant_status_map.keys()), 5)
+
+ def test_006_participant_status_map_forward_lookup(self):
+ # Forward lookups
+ self.assertEqual(self.attendee.participant_status_map["NEEDS-ACTION"], 0)
+ self.assertEqual(self.attendee.participant_status_map["ACCEPTED"], 1)
+ self.assertEqual(self.attendee.participant_status_map["DECLINED"], 2)
+ self.assertEqual(self.attendee.participant_status_map["TENTATIVE"], 3)
+ self.assertEqual(self.attendee.participant_status_map["DELEGATED"], 4)
+
+ def test_007_participant_status_map_reverse_lookup(self):
+ # Reverse lookups
+ self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 0][0], "NEEDS-ACTION")
+ self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 1][0], "ACCEPTED")
+ self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 2][0], "DECLINED")
+ self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 3][0], "TENTATIVE")
+ self.assertEqual([k for k,v in self.attendee.participant_status_map.iteritems() if v == 4][0], "DELEGATED")
+
+ def test_008_default_rsvp(self):
+ self.assertEqual(self.attendee.get_rsvp(), 0)
+
+ def test_009_rsvp_map_length(self):
+ self.assertEqual(len(self.attendee.rsvp_map.keys()), 2)
+
+ def test_010_rsvp_map_forward_lookup_boolean(self):
+ self.assertEqual(self.attendee.rsvp_map["TRUE"], True)
+ self.assertEqual(self.attendee.rsvp_map["FALSE"], False)
+
+ def test_011_rsvp_map_forward_lookup_integer(self):
+ self.assertEqual(self.attendee.rsvp_map["TRUE"], 1)
+ self.assertEqual(self.attendee.rsvp_map["FALSE"], 0)
+
+ def test_012_rsvp_map_reverse_lookup_boolean(self):
+ self.assertEqual([k for k,v in self.attendee.rsvp_map.iteritems() if v == True][0], "TRUE")
+ self.assertEqual([k for k,v in self.attendee.rsvp_map.iteritems() if v == False][0], "FALSE")
+
+ def test_013_rsvp_map_reverse_lookup_integer(self):
+ self.assertEqual([k for k,v in self.attendee.rsvp_map.iteritems() if v == 1][0], "TRUE")
+ self.assertEqual([k for k,v in self.attendee.rsvp_map.iteritems() if v == 0][0], "FALSE")
+
+ def test_014_default_role(self):
+ self.assertEqual(self.attendee.get_role(), 0)
+
+ def test_015_role_map_length(self):
+ self.assertEqual(len(self.attendee.role_map.keys()), 4)
+
+ def test_016_role_map_forward_lookup(self):
+ self.assertEqual(self.attendee.role_map["REQ-PARTICIPANT"], 0)
+ self.assertEqual(self.attendee.role_map["CHAIR"], 1)
+ self.assertEqual(self.attendee.role_map["OPTIONAL"], 2)
+ self.assertEqual(self.attendee.role_map["NONPARTICIPANT"], 3)
+
+ def test_017_role_map_reverse_lookup(self):
+ self.assertEqual([k for k,v in self.attendee.role_map.iteritems() if v == 0][0], "REQ-PARTICIPANT")
+ self.assertEqual([k for k,v in self.attendee.role_map.iteritems() if v == 1][0], "CHAIR")
+ self.assertEqual([k for k,v in self.attendee.role_map.iteritems() if v == 2][0], "OPTIONAL")
+ self.assertEqual([k for k,v in self.attendee.role_map.iteritems() if v == 3][0], "NONPARTICIPANT")
+
+ def test_015_cutype_map_length(self):
+ self.assertEqual(len(self.attendee.cutype_map.keys()), 3)
+
+ def test_016_cutype_map_forward_lookup(self):
+ self.assertEqual(self.attendee.cutype_map["GROUP"], 1)
+ self.assertEqual(self.attendee.cutype_map["INDIVIDUAL"], 2)
+ self.assertEqual(self.attendee.cutype_map["RESOURCE"], 3)
+
+ def test_017_cutype_map_reverse_lookup(self):
+ self.assertEqual([k for k,v in self.attendee.cutype_map.iteritems() if v == 1][0], "GROUP")
+ self.assertEqual([k for k,v in self.attendee.cutype_map.iteritems() if v == 2][0], "INDIVIDUAL")
+ self.assertEqual([k for k,v in self.attendee.cutype_map.iteritems() if v == 3][0], "RESOURCE")
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test-003-event.py b/tests/test-003-event.py
index 3a6a863..031f4a1 100644
--- a/tests/test-003-event.py
+++ b/tests/test-003-event.py
@@ -38,22 +38,18 @@ class TestEventXML(unittest.TestCase):
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.assertIsInstance(self.event.get_attendee_by_email("jane@doe.org"), Attendee)
+ self.assertIsInstance(self.event.get_attendee("jane@doe.org"), Attendee)
+ def test_007_get_nonexistent_attendee_by_email(self):
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.assertIsInstance(self.event.get_attendee_by_name("Doe, Jane"), Attendee)
+ self.assertIsInstance(self.event.get_attendee("Doe, Jane"), Attendee)
+ def test_008_get_nonexistent_attendee_by_name(self):
self.assertRaises(ValueError, self.event.get_attendee_by_name, "Houdini, Harry")
self.assertRaises(ValueError, self.event.get_attendee, "Houdini, Harry")
@@ -66,5 +62,16 @@ class TestEventXML(unittest.TestCase):
def test_011_attendee_equality(self):
self.assertEqual(self.event.get_attendee("jane@doe.org").get_email(), "jane@doe.org")
+ def test_012_delegate_new_attendee(self):
+ self.event.delegate("jane@doe.org", "max@imum.com")
+
+ def test_013_delegatee_is_now_attendee(self):
+ self.assertIsInstance(self.event.get_attendee("max@imum.com"), Attendee)
+
+ def test_014_delegate_attendee_adds(self):
+ self.assertEqual(len(self.event.get_attendee("jane@doe.org").get_delegated_to()), 1)
+ self.event.delegate("jane@doe.org", "john@doe.org")
+ self.assertEqual(len(self.event.get_attendee("jane@doe.org").get_delegated_to()), 2)
+
if __name__ == '__main__':
unittest.main()