From: Rob Golding Date: Fri, 9 Jan 2015 11:22:19 +0000 (+0000) Subject: Add (failing) tests for appending/adding to empty lists/sets X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/48d272800ebe0432e120ec95c357932a23a2cf21?ds=sidebyside Add (failing) tests for appending/adding to empty lists/sets --- diff --git a/tasklib/task.py b/tasklib/task.py index b56936e..d5913af 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -95,7 +95,7 @@ class SerializingObject(object): def deserialize_tags(self, tags): if isinstance(tags, basestring): return tags.split(',') if tags else [] - return tags + return tags or [] def serialize_depends(self, cur_dependencies): # Return the list of uuids diff --git a/tasklib/tests.py b/tasklib/tests.py index f3edd61..a608cf8 100644 --- a/tasklib/tests.py +++ b/tasklib/tests.py @@ -245,6 +245,18 @@ class TaskTest(TasklibTest): self.assertEqual(t['depends'], set([dependency1, dependency2])) + def test_add_to_empty_dependency_set(self): + # Adds dependency to task with one dependencies + t = Task(self.tw, description="test task") + dependency = Task(self.tw, description="needs to be done first") + + dependency.save() + + t['depends'].add(dependency) + t.save() + + self.assertEqual(t['depends'], set([dependency])) + def test_simple_dependency_set_save_repeatedly(self): # Adds only one dependency to task with no dependencies t = Task(self.tw, description="test task") @@ -416,7 +428,6 @@ class TaskTest(TasklibTest): def test_saving_unmodified_task(self): t = Task(self.tw, description="test task") t.save() - t.refresh() t.save() def test_adding_tag_by_appending(self): @@ -424,9 +435,15 @@ class TaskTest(TasklibTest): t.save() t['tags'].append('test2') t.save() - t.refresh() self.assertEqual(t['tags'], ['test1', 'test2']) + def test_adding_tag_by_appending_empty(self): + t = Task(self.tw, description="test task") + t.save() + t['tags'].append('test') + t.save() + self.assertEqual(t['tags'], ['test']) + class AnnotationTest(TasklibTest):