"""Test page requests.""" import re def test_page_that_exists(client): """Test that the app can serve a basic file at the index.""" response = client.get('/') assert response.status_code == 200 assert b'

test index

' in response.data def test_page_that_doesnt_exist(client): """Test that the app returns 404 for nonsense requests.""" response = client.get('/ohuesthaoeusth') assert response.status_code == 404 def test_files_outside_pages_do_not_get_served(client): """Test that page pathing doesn't break out of the instance/pages/ dir.""" response = client.get('/../unreachable') assert response.status_code == 400 def test_weird_paths_do_not_get_served(client): """Test that we clean up requests as desired.""" response = client.get('/../../') assert response.status_code == 400 def test_page_with_title_metadata(client): """Test that a page with title metadata has its title written.""" response = client.get('/') assert response.status_code == 200 assert b'Index - incorporeal.org' in response.data def test_page_without_title_metadata(client): """Test that a page without title metadata gets the default title.""" response = client.get('/no-title') assert response.status_code == 200 assert b'/no-title - incorporeal.org' in response.data def test_page_in_subdir_without_title_metadata(client): """Test that the title-less page display is as expected.""" response = client.get('/subdir//page-no-title') assert response.status_code == 200 assert b'/subdir/page-no-title - incorporeal.org' in response.data def test_page_with_card_metadata(client): """Test that a page with opengraph metadata.""" response = client.get('/more-metadata') assert response.status_code == 200 assert b'' in response.data assert b'' in response.data assert b'' in response.data def test_page_with_card_title_even_when_no_metadata(client): """Test that a page without metadata still has a card with the derived title.""" response = client.get('/no-title') assert response.status_code == 200 assert b'' in response.data assert b'