mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
add test case around ensuring proper field inference for boolean model field types
This commit is contained in:
parent
c3aeb16557
commit
735c75abb9
|
@ -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)
|
||||
|
||||
|
|
|
@ -1720,3 +1720,35 @@ class TestSerializerTransformMethods(TestCase):
|
|||
'b_renamed': None,
|
||||
}
|
||||
)
|
||||
|
||||
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