diff --git a/tests/functional_tests.py b/tests/functional_tests.py index 6bdafd3..714a5c4 100644 --- a/tests/functional_tests.py +++ b/tests/functional_tests.py @@ -1,5 +1,6 @@ """Test page requests.""" import re +from unittest.mock import patch 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 +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): """Test that we clean up requests as desired.""" response = client.get('/../../')