Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test for drf 3.10 #148

Merged
merged 3 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions tests/test_dynamic_routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,24 @@ class Meta:
app_label = 'testapp'


# DRF 3.8+
try:
from rest_framework.decorators import detail_route, list_route
from rest_framework.decorators import action

def detail_route_decorator(**kwargs):
return action(detail=True, **kwargs)

def list_route_decorator(**kwargs):
return action(detail=False, **kwargs)
except ImportError:
pass
else:
# for DRF < 3.8
try:
from rest_framework.decorators import detail_route as detail_route_decorator, list_route as list_route_decorator
except ImportError:
pass


if 'detail_route_decorator' in globals() and 'list_route_decorator' in globals():
def map_by_name(iterable):
ret = {}
for item in iterable:
Expand All @@ -37,15 +50,15 @@ class DetailRouteViewSet(ModelViewSet):
model = BasicModel
queryset = QS(BasicModel)

@detail_route(methods=["post"])
@detail_route_decorator(methods=["post"])
def set_password(self, request, pk=None):
return Response({'hello': 'ok'})

class ListRouteViewSet(ModelViewSet):
model = BasicModel
queryset = QS(BasicModel)

@list_route()
@list_route_decorator()
def recent_users(self, request, pk=None):
return Response([{'hello': 'ok'}])

Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[tox]
envlist =
py27-{flake8,docs},
{py27,py34,py35,py36}-django{1.11}-drf{3.6,3.7,3.8}
{py27,py34}-django1.11-drf{3.6,3.7,3.8,3.9}
{py35,py36,py37}-django1.11-drf{3.6,3.7,3.8,3.9,3.10}
{py34}-django{2.0}-drf{3.7,3.8}
{py35,py36,py37}-django{2.0,2.1,2.2}-drf{3.7,3.8,3.9}
{py35,py36,py37}-django{2.0,2.1,2.2}-drf{3.7,3.8,3.9,3.10}


[testenv]
Expand All @@ -19,6 +20,7 @@ deps =
drf3.7: djangorestframework>=3.7,<3.8
drf3.8: djangorestframework>=3.8,<3.9
drf3.9: djangorestframework>=3.9,<3.10
drf3.10: djangorestframework>=3.10,<3.11
pytest-django==3.4.2
-rrequirements-tox.txt

Expand Down