aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/generics.py
diff options
context:
space:
mode:
authorTom Christie2013-05-28 11:57:11 +0100
committerTom Christie2013-05-28 11:57:11 +0100
commit138f0cacdb0f093a4dc65ef98bf48ddbc27e18b2 (patch)
treed478a9d3df0e658e5096e1d5d5691fe5cb9ad815 /rest_framework/tests/generics.py
parent7123f0b1e6b29778c41476341bd2370f60c279fa (diff)
downloaddjango-rest-framework-138f0cacdb0f093a4dc65ef98bf48ddbc27e18b2.tar.bz2
Raise 404 on incorrect lookup type in URL, not 500. Closes #890.
Diffstat (limited to 'rest_framework/tests/generics.py')
-rw-r--r--rest_framework/tests/generics.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/rest_framework/tests/generics.py b/rest_framework/tests/generics.py
index f091d0db..37734195 100644
--- a/rest_framework/tests/generics.py
+++ b/rest_framework/tests/generics.py
@@ -279,6 +279,16 @@ class TestInstanceView(TestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data, expected)
+ def test_get_instance_view_incorrect_arg(self):
+ """
+ GET requests with an incorrect pk type, should raise 404, not 500.
+ Regression test for #890.
+ """
+ request = factory.get('/a')
+ with self.assertNumQueries(0):
+ response = self.view(request, pk='a').render()
+ self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
+
def test_put_cannot_set_id(self):
"""
PUT requests to create a new object should not be able to set the id.