From: Tomas Babej Date: Sat, 17 Jan 2015 11:36:36 +0000 (+0100) Subject: Tests: Add tests for ensuring serializer and desializer behaviour X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/0e820d870832daaf4fd4cb7c2ecfabcdd3c02420?hp=--cc Tests: Add tests for ensuring serializer and desializer behaviour --- 0e820d870832daaf4fd4cb7c2ecfabcdd3c02420 diff --git a/tasklib/tests.py b/tasklib/tests.py index d498f09..6407221 100644 --- a/tasklib/tests.py +++ b/tasklib/tests.py @@ -477,6 +477,23 @@ class TaskTest(TasklibTest): t.save() self.assertEqual(t['tags'], ['test']) + def test_serializers_returning_empty_string_for_none(self): + # Test that any serializer returns '' when passed None + t = Task(self.tw) + serializers = [getattr(t, serializer_name) for serializer_name in + filter(lambda x: x.startswith('serialize_'), dir(t))] + for serializer in serializers: + self.assertEqual(serializer(None), '') + + def test_deserializer_returning_empty_value_for_empty_string(self): + # Test that any deserializer returns empty value when passed '' + t = Task(self.tw) + deserializers = [getattr(t, deserializer_name) for deserializer_name in + filter(lambda x: x.startswith('deserialize_'), dir(t))] + for deserializer in deserializers: + self.assertTrue(deserializer('') in (None, [], set())) + + class TaskFromHookTest(TasklibTest):