Python rest_framework.mixins.DestroyModelMixin() Examples

The following are 1 code examples of rest_framework.mixins.DestroyModelMixin(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module rest_framework.mixins , or try the search function .
Example #1
Source File: tests.py    From product-definition-center with MIT License 5 votes vote down vote up
def setUp(self):

        class DummySerializer(serializers.Serializer):
            nickname = serializers.CharField()
            color = serializers.CharField()

            def create(self, validated_data):
                return mock.Mock(pk=2, **validated_data)

            def update(self, obj, validated_data):
                return mock.Mock(pk=obj.pk, **validated_data)

        class GetDogMixin(object):
            def get_object(self):
                return mock.Mock(pk=1, nickname='Spot', color='black')

        class DummyView(viewsets.NotificationMixin,
                        mixins.CreateModelMixin,
                        mixins.UpdateModelMixin,
                        mixins.DestroyModelMixin,
                        GetDogMixin,
                        GenericViewSet):
            serializer_class = DummySerializer

        mapping = {
            'post': 'create',
            'put': 'update',
            'delete': 'destroy',
        }
        self.view = DummyView.as_view(mapping, basename='dummy')