mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Add none testcases to date, datetime, time
This commit is contained in:
parent
12905449a5
commit
681ad6f537
|
@ -116,6 +116,15 @@ class DateFieldTest(TestCase):
|
|||
|
||||
self.assertEqual(result, None)
|
||||
|
||||
def test_from_native_none(self):
|
||||
"""
|
||||
Make sure from_native() returns None on None param.
|
||||
"""
|
||||
f = serializers.DateField()
|
||||
result = f.from_native(None)
|
||||
|
||||
self.assertEqual(result, None)
|
||||
|
||||
def test_from_native_invalid_date(self):
|
||||
"""
|
||||
Make sure from_native() raises a ValidationError on passing an invalid date.
|
||||
|
@ -225,6 +234,15 @@ class DateTimeFieldTest(TestCase):
|
|||
|
||||
self.assertEqual(result, None)
|
||||
|
||||
def test_from_native_none(self):
|
||||
"""
|
||||
Make sure from_native() returns None on None param.
|
||||
"""
|
||||
f = serializers.DateTimeField()
|
||||
result = f.from_native(None)
|
||||
|
||||
self.assertEqual(result, None)
|
||||
|
||||
def test_from_native_invalid_datetime(self):
|
||||
"""
|
||||
Make sure from_native() raises a ValidationError on passing an invalid datetime.
|
||||
|
@ -348,6 +366,15 @@ class TimeFieldTest(TestCase):
|
|||
|
||||
self.assertEqual(result, None)
|
||||
|
||||
def test_from_native_none(self):
|
||||
"""
|
||||
Make sure from_native() returns None on None param.
|
||||
"""
|
||||
f = serializers.TimeField()
|
||||
result = f.from_native(None)
|
||||
|
||||
self.assertEqual(result, None)
|
||||
|
||||
def test_from_native_invalid_time(self):
|
||||
"""
|
||||
Make sure from_native() raises a ValidationError on passing an invalid time.
|
||||
|
|
Loading…
Reference in New Issue
Block a user