mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
This commit is contained in:
parent
81709a2c73
commit
806b0b34da
|
@ -133,6 +133,8 @@ class SimpleMetadata(BaseMetadata):
|
|||
|
||||
if getattr(field, 'child', None):
|
||||
field_info['child'] = self.get_field_info(field.child)
|
||||
elif getattr(field, 'fields', None):
|
||||
field_info['children'] = self.get_serializer_info(field)
|
||||
|
||||
if not field_info.get('read_only') and hasattr(field, 'choices'):
|
||||
field_info['choices'] = [
|
||||
|
|
10
runtests.py
10
runtests.py
|
@ -8,7 +8,7 @@ import sys
|
|||
import pytest
|
||||
|
||||
PYTEST_ARGS = {
|
||||
'default': ['tests', '--tb=short', '-s', '--cov', 'rest_framework'],
|
||||
'default': ['tests', '--tb=short', '-s'],
|
||||
'fast': ['tests', '--tb=short', '-q', '-s'],
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,14 @@ if __name__ == "__main__":
|
|||
if len(sys.argv) > 1:
|
||||
pytest_args = sys.argv[1:]
|
||||
first_arg = pytest_args[0]
|
||||
|
||||
try:
|
||||
pytest_args.remove('--coverage')
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
pytest_args = ['--cov', 'rest_framework'] + pytest_args
|
||||
|
||||
if first_arg.startswith('-'):
|
||||
# `runtests.py [flags]`
|
||||
pytest_args = ['tests'] + pytest_args
|
||||
|
|
|
@ -59,6 +59,10 @@ class TestMetadata:
|
|||
On generic views OPTIONS should return an 'actions' key with metadata
|
||||
on the fields that may be supplied to PUT and POST requests.
|
||||
"""
|
||||
class NestedField(serializers.Serializer):
|
||||
a = serializers.IntegerField()
|
||||
b = serializers.IntegerField()
|
||||
|
||||
class ExampleSerializer(serializers.Serializer):
|
||||
choice_field = serializers.ChoiceField(['red', 'green', 'blue'])
|
||||
integer_field = serializers.IntegerField(
|
||||
|
@ -72,6 +76,7 @@ class TestMetadata:
|
|||
child=serializers.IntegerField()
|
||||
)
|
||||
)
|
||||
nested_field = NestedField()
|
||||
|
||||
class ExampleView(views.APIView):
|
||||
"""Example view."""
|
||||
|
@ -140,6 +145,26 @@ class TestMetadata:
|
|||
'read_only': False
|
||||
}
|
||||
}
|
||||
},
|
||||
'nested_field': {
|
||||
'type': 'nested object',
|
||||
'required': True,
|
||||
'read_only': False,
|
||||
'label': 'Nested field',
|
||||
'children': {
|
||||
'a': {
|
||||
'type': 'integer',
|
||||
'required': True,
|
||||
'read_only': False,
|
||||
'label': 'A'
|
||||
},
|
||||
'b': {
|
||||
'type': 'integer',
|
||||
'required': True,
|
||||
'read_only': False,
|
||||
'label': 'B'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user