diff options
author | Aleksander Machniak <machniak@kolabsys.com> | 2016-10-06 09:43:14 +0200 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2016-10-06 09:43:14 +0200 |
commit | 8478ac6830d0002c77ce9b23ca6e1fd35fbec464 (patch) | |
tree | 23eb94cbc7df512954c4bfa09d539bb6010328c7 | |
parent | ee6b450f2fabebaf18d7e7d7ea36d693ecd546ea (diff) | |
download | pykolab-8478ac6830d0002c77ce9b23ca6e1fd35fbec464.tar.gz |
T1221: Fix a "race" between Event and Todo properties_map dict
Summary: Fixes T1221
Reviewers: #pykolab_developers, vanmeeuwen
Reviewed By: #pykolab_developers, vanmeeuwen
Maniphest Tasks: T1221
Differential Revision: https://git.kolab.org/D216
-rw-r--r-- | pykolab/xml/todo.py | 3 | ||||
-rw-r--r-- | tests/unit/test-003-event.py | 4 | ||||
-rw-r--r-- | tests/unit/test-017-diff.py | 19 |
3 files changed, 15 insertions, 11 deletions
diff --git a/pykolab/xml/todo.py b/pykolab/xml/todo.py index f73f239..ccd798f 100644 --- a/pykolab/xml/todo.py +++ b/pykolab/xml/todo.py @@ -38,6 +38,9 @@ def todo_from_message(message): class Todo(Event): type = 'task' + # This have to be a copy (see T1221) + properties_map = Event.properties_map.copy() + def __init__(self, from_ical="", from_string=""): self._attendees = [] self._categories = [] diff --git a/tests/unit/test-003-event.py b/tests/unit/test-003-event.py index a7ab82f..09ab17d 100644 --- a/tests/unit/test-003-event.py +++ b/tests/unit/test-003-event.py @@ -889,7 +889,7 @@ END:VEVENT self.assertIsInstance(data, dict) self.assertIsInstance(data['start'], datetime.datetime) - # self.assertIsInstance(data['end'], datetime.datetime) + self.assertIsInstance(data['end'], datetime.datetime) self.assertIsInstance(data['created'], datetime.datetime) self.assertIsInstance(data['lastmodified-date'], datetime.datetime) self.assertEqual(data['uid'], '75c740bb-b3c6-442c-8021-ecbaeb0a025e') @@ -936,7 +936,7 @@ END:VEVENT e2.set_lastmodified() diff = compute_diff(e1.to_dict(), e2.to_dict(), True) - self.assertEqual(len(diff), 4, "Diff: (length: %d):\r\n%r\r\n%r" % (len(diff), diff, e2.__str__())) + self.assertEqual(len(diff), 5, "Diff: (length: %d):\r\n%r\r\n%r" % (len(diff), diff, e2.__str__())) ps = self._find_prop_in_list(diff, 'summary') self.assertIsInstance(ps, OrderedDict) diff --git a/tests/unit/test-017-diff.py b/tests/unit/test-017-diff.py index 46e0a77..4adbea1 100644 --- a/tests/unit/test-017-diff.py +++ b/tests/unit/test-017-diff.py @@ -190,18 +190,19 @@ class TestComputeDiff(unittest.TestCase): self.assertEqual(diff[0]['old'], 0) self.assertEqual(diff[0]['new'], 1) - self.assertEqual(diff[1]['property'], 'description') - self.assertEqual(diff[1]['old'], '') + self.assertEqual(diff[1]['property'], 'summary') + self.assertEqual(diff[1]['old'], 'Old attachments') + self.assertEqual(diff[1]['new'], 'New attachments') - self.assertEqual(diff[2]['property'], 'summary') - self.assertEqual(diff[2]['old'], 'Old attachments') - self.assertEqual(diff[2]['new'], 'New attachments') + self.assertEqual(diff[2]['property'], 'attach') + self.assertEqual(diff[2]['new'], None) + self.assertEqual(diff[2]['old']['uri'], "cid:silhouette.1427297477.7514.png") - self.assertEqual(diff[3]['property'], 'attach') - self.assertEqual(diff[3]['new'], None) - self.assertEqual(diff[3]['old']['uri'], "cid:silhouette.1427297477.7514.png") + self.assertEqual(diff[3]['property'], 'lastmodified-date') + + self.assertEqual(diff[4]['property'], 'description') + self.assertEqual(diff[4]['old'], '') - self.assertEqual(diff[4]['property'], 'lastmodified-date') if __name__ == '__main__': unittest.main() |