From 87208021e289d56eeed7fc4a9802ba8dacb3d30b Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Tue, 24 Mar 2015 21:31:35 -0400 Subject: [PATCH] Metadata should detect null boolean field type. --- rest_framework/metadata.py | 1 + tests/test_metadata.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rest_framework/metadata.py b/rest_framework/metadata.py index bf3611aa33..b2c48b816f 100644 --- a/rest_framework/metadata.py +++ b/rest_framework/metadata.py @@ -36,6 +36,7 @@ class SimpleMetadata(BaseMetadata): label_lookup = ClassLookupDict({ serializers.Field: 'field', serializers.BooleanField: 'boolean', + serializers.NullBooleanField: 'boolean', serializers.CharField: 'string', serializers.URLField: 'url', serializers.EmailField: 'email', diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 3a435f02f1..731aedba3f 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -1,5 +1,5 @@ from __future__ import unicode_literals -from rest_framework import exceptions, serializers, status, views, versioning +from rest_framework import exceptions, metadata, serializers, status, views, versioning from rest_framework.request import Request from rest_framework.renderers import BrowsableAPIRenderer from rest_framework.test import APIRequestFactory @@ -207,3 +207,8 @@ def get_serializer(self): scheme = versioning.QueryParameterVersioning view = ExampleView.as_view(versioning_class=scheme) view(request=request) + + def test_null_boolean_field_info_type(self): + options = metadata.SimpleMetadata() + field_info = options.get_field_info(serializers.NullBooleanField()) + assert field_info['type'] == 'boolean'