'On generic views OPTIONS should return an \'actions\' key with metadata
on the fields that may be supplied to PUT and POST requests. It should
not fail when a read_only PrimaryKeyRelatedField is present'

def test_read_only_primary_key_related_field(self):

    class Parent(models.Model, ):
        integer_field = models.IntegerField(validators=[MinValueValidator(1), MaxValueValidator(1000)])
        children = models.ManyToManyField(u'Child')
        name = models.CharField(max_length=100, blank=True, null=True)
    class Child(models.Model, ):
        name = models.CharField(max_length=100)
    class ExampleSerializer(serializers.ModelSerializer, ):
        children = serializers.PrimaryKeyRelatedField(read_only=True, many=True)
        class Meta:
            model = Parent
            fields = u'__all__'
    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'id': {u'type': u'integer', u'required': False, u'read_only': True, u'label': u'ID'}, u'children': {u'type': u'field', u'required': False, u'read_only': True, u'label': u'Children'}, 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'name': {u'type': u'string', u'required': False, u'read_only': False, u'label': u'Name', u'max_length': 100}}}}
    assert (response.status_code == status.HTTP_200_OK)
    assert (response.data == expected)
