Added failing test cases for giving a DateField or DateTimeField a None value to serialize.

Signed-off-by: Kevin Stone <kevinastone@gmail.com>
This commit is contained in:
Kevin Stone 2013-03-06 15:15:19 -08:00
parent 751064a6fd
commit 6bea275de8

View File

@ -171,6 +171,13 @@ class DateFieldTest(TestCase):
self.assertEqual('1984 - 07.31', result_1)
def test_to_native_none(self):
"""
Make sure from_native() returns None on None param.
"""
f = serializers.DateField(required=False)
self.assertEqual(None, f.to_native(None))
class DateTimeFieldTest(TestCase):
"""
@ -303,6 +310,13 @@ class DateTimeFieldTest(TestCase):
self.assertEqual('1984 - 04:31', result_3)
self.assertEqual('1984 - 04:31', result_4)
def test_to_native_none(self):
"""
Make sure from_native() returns None on None param.
"""
f = serializers.DateTimeField(required=False)
self.assertEqual(None, f.to_native(None))
class TimeFieldTest(TestCase):
"""