'On generic views OPTIONS should return an \'actions\' key with metadata
on the fields that may be supplied to PUT and POST requests.'

def test_actions(self):

    class NestedField(serializers.Serializer, ):
        a = serializers.IntegerField()
        b = serializers.IntegerField()
    class ExampleSerializer(serializers.Serializer, ):
        choice_field = serializers.ChoiceField([u'red', u'green', u'blue'])
        integer_field = serializers.IntegerField(min_value=1, max_value=1000)
        char_field = serializers.CharField(required=False, min_length=3, max_length=40)
        list_field = serializers.ListField(child=serializers.ListField(child=serializers.IntegerField()))
        nested_field = NestedField()
    class ExampleView(views.APIView, ):
        u'Example    view.'
        def post(self, request):
            pass
        def get_serializer(self):
            return ExampleSerializer()
    view = ExampleView.as_view()
    response = view(request=request)
    expected = {u'name': u'Example', u'description': u'Example    view.', u'renders': [u'application/json', u'text/html'], u'parses': [u'application/json', u'application/x-www-form-urlencoded', u'multipart/form-data'], u'actions': {u'POST': {u'choice_field': {u'type': u'choice', u'required': True, u'read_only': False, u'label': u'Choice    field', u'choices': [{u'display_name': u'red', u'value': u'red'}, {u'display_name': u'green', u'value': u'green'}, {u'display_name': u'blue', u'value': u'blue'}]}, u'integer_field': {u'type': u'integer', u'required': True, u'read_only': False, u'label': u'Integer    field', u'min_value': 1, u'max_value': 1000}, u'char_field': {u'type': u'string', u'required': False, u'read_only': False, u'label': u'Char    field', u'min_length': 3, u'max_length': 40}, u'list_field': {u'type': u'list', u'required': True, u'read_only': False, u'label': u'List    field', u'child': {u'type': u'list', u'required': True, u'read_only': False, u'child': {u'type': u'integer', u'required': True, u'read_only': False}}}, u'nested_field': {u'type': u'nested    object', u'required': True, u'read_only': False, u'label': u'Nested    field', u'children': {u'a': {u'type': u'integer', u'required': True, u'read_only': False, u'label': u'A'}, u'b': {u'type': u'integer', u'required': True, u'read_only': False, u'label': u'B'}}}}}}
    assert (response.status_code == status.HTTP_200_OK)
    assert (response.data == expected)
