From 388eedb83ce4926cfab2931a96eeb8056bda1f7d Mon Sep 17 00:00:00 2001 From: Guillaume Camera Date: Thu, 7 Sep 2017 11:46:32 +0200 Subject: [PATCH] refs #257, Fix the exception raised when formidable not found --- demo/tests/test_integration.py | 14 ++++++++++++++ formidable/views.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/demo/tests/test_integration.py b/demo/tests/test_integration.py index 5c9c23fa..25420de1 100644 --- a/demo/tests/test_integration.py +++ b/demo/tests/test_integration.py @@ -410,6 +410,20 @@ def test_validate_data_ok(self): ) self.assertEqual(res.status_code, 204) + def test_validate_does_not_exist(self): + parameters = { + 'first_name': 'Guillaume', + 'last_name': 'Gérard', + } + session = self.client.session + session['role'] = 'padawan' + session.save() + res = self.client.get( + reverse(self.url, args=[9999]), + parameters, format='json' + ) + self.assertEqual(res.status_code, 404) + def test_validate_data_ko(self): parameters = { 'last_name': 'Gérard', diff --git a/formidable/views.py b/formidable/views.py index f1e4836e..d5d752dc 100644 --- a/formidable/views.py +++ b/formidable/views.py @@ -242,7 +242,7 @@ def get(self, request, **kwargs): try: formidable = self.get_formidable_object(kwargs) except Formidable.DoesNotExist: - raise exceptions.Http404() + raise exceptions.NotFound() form_class = self.get_form_class(formidable) form = self.get_form(form_class)