diff options
| author | Tom Christie | 2013-06-27 12:32:46 +0100 |
|---|---|---|
| committer | Tom Christie | 2013-06-27 12:32:46 +0100 |
| commit | e0dddbc5de88f5afd4c36a8bdb05d83cca79960d (patch) | |
| tree | 31c19f68ca4701946d34676b8ae8a06186a1dee0 /rest_framework/tests | |
| parent | 96f41fd12d376833a5822918cedcec5e74d59d02 (diff) | |
| parent | 7e67ad666bf67a60fc4ca67ff2b58bf3fddd42c7 (diff) | |
| download | django-rest-framework-e0dddbc5de88f5afd4c36a8bdb05d83cca79960d.tar.bz2 | |
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework
Diffstat (limited to 'rest_framework/tests')
| -rw-r--r-- | rest_framework/tests/test_routers.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/rest_framework/tests/test_routers.py b/rest_framework/tests/test_routers.py index fe0711fa..d375f4a8 100644 --- a/rest_framework/tests/test_routers.py +++ b/rest_framework/tests/test_routers.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals from django.db import models from django.test import TestCase from django.test.client import RequestFactory +from django.core.exceptions import ImproperlyConfigured from rest_framework import serializers, viewsets, permissions from rest_framework.compat import include, patterns, url from rest_framework.decorators import link, action @@ -191,3 +192,24 @@ class TestActionKeywordArgs(TestCase): response.data, {'permission_classes': [permissions.AllowAny]} ) + +class TestActionAppliedToExistingRoute(TestCase): + """ + Ensure `@action` decorator raises an except when applied + to an existing route + """ + + def test_exception_raised_when_action_applied_to_existing_route(self): + class TestViewSet(viewsets.ModelViewSet): + + @action() + def retrieve(self, request, *args, **kwargs): + return Response({ + 'hello': 'world' + }) + + self.router = SimpleRouter() + self.router.register(r'test', TestViewSet, base_name='test') + + with self.assertRaises(ImproperlyConfigured): + self.router.urls |
