diff options
| author | Tom Christie | 2013-01-19 15:51:14 +0000 |
|---|---|---|
| committer | Tom Christie | 2013-01-19 15:51:14 +0000 |
| commit | 37d49429ca34eed86ea142e5dceea4cd9536df2d (patch) | |
| tree | 320e1cf454916fe89a324c22b6e4f9fac7bd3716 /rest_framework/tests | |
| parent | af3fd098459fb559788735cb6b49a7108e11b18e (diff) | |
| download | django-rest-framework-37d49429ca34eed86ea142e5dceea4cd9536df2d.tar.bz2 | |
Raise assertion errors if @api_view decorator is applied incorrectly. Fixes #596.
Diffstat (limited to 'rest_framework/tests')
| -rw-r--r-- | rest_framework/tests/decorators.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/rest_framework/tests/decorators.py b/rest_framework/tests/decorators.py index 4012188d..82f912e9 100644 --- a/rest_framework/tests/decorators.py +++ b/rest_framework/tests/decorators.py @@ -28,6 +28,28 @@ class DecoratorTestCase(TestCase): response.request = request return APIView.finalize_response(self, request, response, *args, **kwargs) + def test_api_view_incorrect(self): + """ + If @api_view is not applied correct, we should raise an assertion. + """ + + @api_view + def view(request): + return Response() + + request = self.factory.get('/') + self.assertRaises(AssertionError, view, request) + + def test_api_view_incorrect_arguments(self): + """ + If @api_view is missing arguments, we should raise an assertion. + """ + + with self.assertRaises(AssertionError): + @api_view('GET') + def view(request): + return Response() + def test_calling_method(self): @api_view(['GET']) |
