0001-misc-return-HTTP-404-instead-of-500-for-GET-requests.patch
passerelle/views.py | ||
---|---|---|
33 | 33 |
from django.db import transaction |
34 | 34 |
from django.db.models import Q |
35 | 35 |
from django.http import Http404, HttpResponse, HttpResponseRedirect |
36 |
from django.shortcuts import resolve_url |
|
36 |
from django.shortcuts import get_object_or_404, resolve_url
|
|
37 | 37 |
from django.urls import reverse |
38 | 38 |
from django.utils.encoding import force_bytes, force_text |
39 | 39 |
from django.utils.timezone import is_naive, make_aware |
... | ... | |
238 | 238 |
return context |
239 | 239 | |
240 | 240 |
def get_object(self): |
241 |
return self.model.objects.get(slug=self.kwargs['slug'])
|
|
241 |
return get_object_or_404(self.model.objects.all(), slug=self.kwargs['slug'])
|
|
242 | 242 | |
243 | 243 |
def get_queryset(self): |
244 | 244 |
self.form = ResourceLogSearchForm(data=self.request.GET) |
tests/test_views.py | ||
---|---|---|
1 |
from tests.test_manager import login |
|
2 | ||
3 | ||
4 |
def test_get_does_not_crash_on_unknown_connector(app, db, admin_user): |
|
5 |
app = login(app) |
|
6 | ||
7 |
resp = app.get('/manage/opengis/noop/logs/', status="*") |
|
8 | ||
9 |
assert resp.status_code == 404 |
|
0 |
- |