mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Merge branch 'nullbooleanfield_testcase' of git://github.com/dpetzel/django-rest-framework into dpetzel-nullbooleanfield_testcase
Conflicts: rest_framework/tests/test_serializer.py
This commit is contained in:
commit
8894019899
|
@ -70,6 +70,7 @@ class Comment(RESTFrameworkModel):
|
|||
|
||||
class ActionItem(RESTFrameworkModel):
|
||||
title = models.CharField(max_length=200)
|
||||
started = models.NullBooleanField(default=False)
|
||||
done = models.BooleanField(default=False)
|
||||
info = CustomField(default='---', max_length=12)
|
||||
|
||||
|
|
|
@ -1807,3 +1807,36 @@ class SerializerDefaultTrueBoolean(TestCase):
|
|||
self.assertEqual(serializer.is_valid(), True)
|
||||
self.assertEqual(serializer.data['cat'], False)
|
||||
self.assertEqual(serializer.data['dog'], False)
|
||||
|
||||
|
||||
class BoolenFieldTypeTest(TestCase):
|
||||
'''
|
||||
Ensure the various Boolean based model fields are rendered as the proper
|
||||
field type
|
||||
|
||||
'''
|
||||
|
||||
def setUp(self):
|
||||
'''
|
||||
Setup an ActionItemSerializer for BooleanTesting
|
||||
'''
|
||||
data = {
|
||||
'title': 'b' * 201,
|
||||
}
|
||||
self.serializer = ActionItemSerializer(data=data)
|
||||
|
||||
def test_booleanfield_type(self):
|
||||
'''
|
||||
Test that BooleanField is infered from models.BooleanField
|
||||
'''
|
||||
bfield = self.serializer.get_fields()['done']
|
||||
self.assertEqual(type(bfield), fields.BooleanField)
|
||||
|
||||
def test_nullbooleanfield_type(self):
|
||||
'''
|
||||
Test that BooleanField is infered from models.NullBooleanField
|
||||
|
||||
https://groups.google.com/forum/#!topic/django-rest-framework/D9mXEftpuQ8
|
||||
'''
|
||||
bfield = self.serializer.get_fields()['started']
|
||||
self.assertEqual(type(bfield), fields.BooleanField)
|
||||
|
|
Loading…
Reference in New Issue
Block a user