misc: use django handler for 404 pages (#30403)
This commit is contained in:
parent
9d04ffd779
commit
7a4de10ba3
|
@ -13,6 +13,7 @@ import pytest
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
|
from django.http import Http404
|
||||||
from django.test import override_settings
|
from django.test import override_settings
|
||||||
from quixote import cleanup
|
from quixote import cleanup
|
||||||
from wcs.qommon.http_request import HTTPRequest
|
from wcs.qommon.http_request import HTTPRequest
|
||||||
|
@ -113,13 +114,13 @@ def test_finish_interrupted_request():
|
||||||
})
|
})
|
||||||
response = pub.process_request(req)
|
response = pub.process_request(req)
|
||||||
assert 'Invalid request: multipart/form-data missing boundary' in str(response)
|
assert 'Invalid request: multipart/form-data missing boundary' in str(response)
|
||||||
req = HTTPRequest(StringIO.StringIO(''), {
|
with pytest.raises(Http404):
|
||||||
'SERVER_NAME': 'example.net',
|
req = HTTPRequest(StringIO.StringIO(''), {
|
||||||
'SCRIPT_NAME': '',
|
'SERVER_NAME': 'example.net',
|
||||||
'PATH_INFO': '/gloubiboulga',
|
'SCRIPT_NAME': '',
|
||||||
})
|
'PATH_INFO': '/gloubiboulga',
|
||||||
response = pub.process_request(req)
|
})
|
||||||
assert '<p>The requested link' in str(response)
|
response = pub.process_request(req)
|
||||||
|
|
||||||
def test_get_tenants():
|
def test_get_tenants():
|
||||||
pub = create_temporary_pub()
|
pub = create_temporary_pub()
|
||||||
|
|
|
@ -173,6 +173,8 @@ class QommonPublisher(Publisher, object):
|
||||||
if request.is_json():
|
if request.is_json():
|
||||||
request.response.set_content_type('application/json')
|
request.response.set_content_type('application/json')
|
||||||
return json.dumps({'err': 1, 'err_class': exc.title, 'err_desc': exc.public_msg})
|
return json.dumps({'err': 1, 'err_class': exc.title, 'err_desc': exc.public_msg})
|
||||||
|
if isinstance(exc, errors.TraversalError):
|
||||||
|
raise Http404()
|
||||||
output = self.format_publish_error(exc)
|
output = self.format_publish_error(exc)
|
||||||
self.session_manager.finish_successful_request()
|
self.session_manager.finish_successful_request()
|
||||||
return output
|
return output
|
||||||
|
|
Loading…
Reference in New Issue