summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2019-11-08 10:29:18 +0000
committerAleksander Machniak <machniak@kolabsys.com>2019-11-08 10:29:18 +0000
commitef85ddea076263eb774c1e91a38cdb87a4ba9792 (patch)
tree91905bde38cc6c1e053ed9d353de7307fe9e78eb
parent726512ce5cabc82dc31ca4f8d7e40aa4f55f0028 (diff)
downloadpykolab-ef85ddea076263eb774c1e91a38cdb87a4ba9792.tar.gz
T5641: Support CUTYPE=ROOM and CUTYPE=UNKNOWN
-rw-r--r--pykolab/xml/attendee.py2
-rw-r--r--tests/unit/test-002-attendee.py22
-rw-r--r--tests/unit/test-003-event.py4
3 files changed, 19 insertions, 9 deletions
diff --git a/pykolab/xml/attendee.py b/pykolab/xml/attendee.py
index e7d0e23..41447db 100644
--- a/pykolab/xml/attendee.py
+++ b/pykolab/xml/attendee.py
@@ -33,6 +33,8 @@ class Attendee(kolabformat.Attendee):
"INDIVIDUAL": kolabformat.CutypeIndividual,
"RESOURCE": kolabformat.CutypeResource,
"GROUP": kolabformat.CutypeGroup,
+ "ROOM": kolabformat.CutypeRoom,
+ "UNKNOWN": kolabformat.CutypeUnknown,
}
participant_status_map = {
diff --git a/tests/unit/test-002-attendee.py b/tests/unit/test-002-attendee.py
index c90c48e..65eb820 100644
--- a/tests/unit/test-002-attendee.py
+++ b/tests/unit/test-002-attendee.py
@@ -4,6 +4,7 @@ import kolabformat
from pykolab.xml import Attendee
from pykolab.xml import participant_status_label
+from pykolab.xml.attendee import InvalidAttendeeCutypeError
class TestEventXML(unittest.TestCase):
@@ -96,17 +97,21 @@ class TestEventXML(unittest.TestCase):
self.assertEqual([k for k, v in self.attendee.role_map.iteritems() if v == 3][0], "NON-PARTICIPANT")
def test_015_cutype_map_length(self):
- self.assertEqual(len(self.attendee.cutype_map.keys()), 3)
+ self.assertEqual(len(self.attendee.cutype_map.keys()), 5)
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)
+ self.assertEqual(self.attendee.cutype_map["GROUP"], kolabformat.CutypeGroup)
+ self.assertEqual(self.attendee.cutype_map["INDIVIDUAL"], kolabformat.CutypeIndividual)
+ self.assertEqual(self.attendee.cutype_map["RESOURCE"], kolabformat.CutypeResource)
+ self.assertEqual(self.attendee.cutype_map["ROOM"], kolabformat.CutypeRoom)
+ self.assertEqual(self.attendee.cutype_map["UNKNOWN"], kolabformat.CutypeUnknown)
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")
+ self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeGroup][0], "GROUP")
+ self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeIndividual][0], "INDIVIDUAL")
+ self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeResource][0], "RESOURCE")
+ self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeRoom][0], "ROOM")
+ self.assertEqual([k for k, v in self.attendee.cutype_map.iteritems() if v == kolabformat.CutypeUnknown][0], "UNKNOWN")
def test_018_partstat_label(self):
self.assertEqual(participant_status_label('NEEDS-ACTION'), "Needs Action")
@@ -133,5 +138,8 @@ class TestEventXML(unittest.TestCase):
self.assertEqual(data['email'], 'jane@doe.org')
self.assertTrue(data['rsvp'])
+ def test_030_to_cutype_exception(self):
+ self.assertRaises(InvalidAttendeeCutypeError, self.attendee.set_cutype, "DUMMY")
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/unit/test-003-event.py b/tests/unit/test-003-event.py
index 9959ec6..8b23830 100644
--- a/tests/unit/test-003-event.py
+++ b/tests/unit/test-003-event.py
@@ -41,7 +41,7 @@ SEQUENCE:2
CLASS:PUBLIC
ATTENDEE;CN="Manager, Jane";PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;CUTYP
E=INDIVIDUAL;RSVP=TRUE:mailto:jane.manager@example.org
-ATTENDEE;CUTYPE=RESOURCE;PARTSTAT=NEEDS-ACTION;ROLE=OPT-PARTICIPANT;RSVP=FA
+ATTENDEE;CUTYPE=ROOM;PARTSTAT=NEEDS-ACTION;ROLE=OPT-PARTICIPANT;RSVP=FA
LSE:MAILTO:max@imum.com
ORGANIZER;CN=Doe\, John:mailto:john.doe@example.org
URL:http://somelink.com/foo
@@ -495,7 +495,7 @@ METHOD:REQUEST
self.assertEqual(event.get_categories(), ["Personal"])
self.assertEqual(event.get_priority(), '2')
self.assertEqual(event.get_classification(), kolabformat.ClassPublic)
- self.assertEqual(event.get_attendee_by_email("max@imum.com").get_cutype(), kolabformat.CutypeResource)
+ self.assertEqual(event.get_attendee_by_email("max@imum.com").get_cutype(), kolabformat.CutypeRoom)
self.assertEqual(event.get_sequence(), 2)
self.assertTrue(event.is_recurring())
self.assertIsInstance(event.get_duration(), datetime.timedelta)