Skip to content

Commit

Permalink
Add an APIView with an <int:pk> captured value to demonstrate tfranze…
Browse files Browse the repository at this point in the history
  • Loading branch information
maerteijn committed Sep 2, 2020
1 parent 37c297d commit f1f5f8f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/test_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.conf.urls import include
from django.db import models
from django.urls import path, re_path
from rest_framework import mixins, routers, serializers, viewsets
from rest_framework import generics, mixins, routers, serializers, viewsets
from rest_framework.test import APIClient
from rest_framework.versioning import AcceptHeaderVersioning, NamespaceVersioning, URLPathVersioning

Expand Down Expand Up @@ -45,6 +45,12 @@ class NamespaceVersioningViewset(PathVersioningViewset):
versioning_class = NamespaceVersioning


class NamespaceVersioningAPIView(generics.RetrieveUpdateDestroyAPIView):
versioning_class = NamespaceVersioning
serializer_class = Xv1Serializer
queryset = VersioningModel.objects.all()


class AcceptHeaderVersioningViewset(PathVersioningViewset):
versioning_class = AcceptHeaderVersioning

Expand Down Expand Up @@ -119,6 +125,7 @@ def test_accept_header_versioning(no_warnings, viewset_cls, version):

urlpatterns_namespace = [
path('x/', NamespaceVersioningViewset.as_view({'get': 'list'})),
path('y/<int:pk>/', NamespaceVersioningAPIView.as_view()),
path('schema/', SpectacularAPIView.as_view(
versioning_class=NamespaceVersioning
), name='schema-nv-versioned'),
Expand Down

0 comments on commit f1f5f8f

Please sign in to comment.