From 0e820d870832daaf4fd4cb7c2ecfabcdd3c02420 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 17 Jan 2015 12:36:36 +0100 Subject: [PATCH] Tests: Add tests for ensuring serializer and desializer behaviour --- tasklib/tests.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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): -- 2.39.5