summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-01-28 15:48:16 +0100
committerThomas Bruederli <bruederli@kolabsys.com>2015-01-28 15:48:16 +0100
commitb8743d943a1bbb2a6fd639d7548eb435899b2829 (patch)
treeee44da417d43ce912f7f0cc5ffe5a1067b48f6f0
parent76dce1ed329e4397648e4c159ece94c598c503d1 (diff)
downloadpykolab-b8743d943a1bbb2a6fd639d7548eb435899b2829.tar.gz
Don't raise exceptions when setting event/todo status to StatusUndefined, which is a valid value (#4304)
-rw-r--r--pykolab/xml/__init__.py1
-rw-r--r--pykolab/xml/event.py2
-rw-r--r--tests/unit/test-016-todo.py12
3 files changed, 11 insertions, 4 deletions
diff --git a/pykolab/xml/__init__.py b/pykolab/xml/__init__.py
index 2c99717..00edf06 100644
--- a/pykolab/xml/__init__.py
+++ b/pykolab/xml/__init__.py
@@ -9,6 +9,7 @@ from recurrence_rule import RecurrenceRule
from event import Event
from event import EventIntegrityError
from event import InvalidEventDateError
+from event import InvalidEventStatusError
from event import event_from_ical
from event import event_from_string
from event import event_from_message
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 72c5e07..625f555 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -851,7 +851,7 @@ class Event(object):
self.event.setStatus(self.status_map[status])
elif status in self.status_map.values():
self.event.setStatus(status)
- else:
+ elif not status == kolabformat.StatusUndefined:
raise InvalidEventStatusError, _("Invalid status set: %r") % (status)
def set_summary(self, summary):
diff --git a/tests/unit/test-016-todo.py b/tests/unit/test-016-todo.py
index c6a1178..2e55c63 100644
--- a/tests/unit/test-016-todo.py
+++ b/tests/unit/test-016-todo.py
@@ -8,6 +8,7 @@ import icalendar
from pykolab.xml import Attendee
from pykolab.xml import Todo
from pykolab.xml import TodoIntegrityError
+from pykolab.xml import InvalidEventStatusError
from pykolab.xml import todo_from_ical
from pykolab.xml import todo_from_string
from pykolab.xml import todo_from_message
@@ -164,15 +165,20 @@ class TestTodoXML(unittest.TestCase):
self.assertIsInstance(self.todo.__str__(), str)
def test_002_full(self):
- pass
+ self.todo.set_summary("test full")
+ status = self.todo.get_status()
+ self.assertEqual(status, kolabformat.StatusUndefined)
+ self.assertRaises(InvalidEventStatusError, self.todo.set_status, (-1))
+ self.todo.set_status(status)
+ # TODO: add more setters and getter tests here
def test_010_load_from_xml(self):
todo = todo_from_string(xml_todo)
self.assertEqual(todo.uid, '18C2EBBD8B31D99F7AA578EDFDFB1AC0-FCBB6C4091F28CA0')
self.assertEqual(todo.get_sequence(), 3)
self.assertIsInstance(todo.get_due(), datetime.datetime)
- self.assertEqual(str(todo.get_due()), "2014-08-22 13:30:00+01:00")
- self.assertEqual(str(todo.get_start()), "2014-08-18 18:00:00+01:00")
+ self.assertEqual(str(todo.get_due()), "2014-08-22 13:30:00+02:00")
+ self.assertEqual(str(todo.get_start()), "2014-08-18 18:00:00+02:00")
self.assertEqual(todo.get_categories(), ['iTip'])
self.assertEqual(todo.get_attendee_by_email("john@example.org").get_participant_status(), kolabformat.PartNeedsAction)
self.assertIsInstance(todo.get_organizer(), kolabformat.ContactReference)