add some 500 tests for test coverage
This commit is contained in:
parent
6705fa38eb
commit
1ac13f3b9c
@ -1,5 +1,6 @@
|
|||||||
"""Test page requests."""
|
"""Test page requests."""
|
||||||
import re
|
import re
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
|
||||||
def test_page_that_exists(client):
|
def test_page_that_exists(client):
|
||||||
@ -41,6 +42,24 @@ def test_internal_server_error_serves_error_page(client):
|
|||||||
assert b'bss@incorporeal.org' in response.data
|
assert b'bss@incorporeal.org' in response.data
|
||||||
|
|
||||||
|
|
||||||
|
def test_oserror_is_500(client, app):
|
||||||
|
"""Test that an OSError raises as a 500."""
|
||||||
|
with app.test_request_context():
|
||||||
|
with patch('flask.current_app.open_instance_resource', side_effect=OSError):
|
||||||
|
response = client.get('/')
|
||||||
|
assert response.status_code == 500
|
||||||
|
assert b'INTERNAL SERVER ERROR' in response.data
|
||||||
|
|
||||||
|
|
||||||
|
def test_unsupported_file_type_is_500(client, app):
|
||||||
|
"""Test a coding condition mishap raises as a 500."""
|
||||||
|
with app.test_request_context():
|
||||||
|
with patch('incorporealcms.pages.request_path_to_instance_resource_path', return_value=('foo', 'bar')):
|
||||||
|
response = client.get('/')
|
||||||
|
assert response.status_code == 500
|
||||||
|
assert b'INTERNAL SERVER ERROR' in response.data
|
||||||
|
|
||||||
|
|
||||||
def test_weird_paths_do_not_get_served(client):
|
def test_weird_paths_do_not_get_served(client):
|
||||||
"""Test that we clean up requests as desired."""
|
"""Test that we clean up requests as desired."""
|
||||||
response = client.get('/../../')
|
response = client.get('/../../')
|
||||||
|
Loading…
Reference in New Issue
Block a user