"""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'<h1>test index</h1>' 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_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'<title>Index - incorporeal.org</title>' 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'<title>incorporeal.org</title>' in response.data assert b'<h1>this page doesn\'t have a title!</h1>' in response.data def test_page_has_modified_timestamp(client): """Test that pages have modified timestamps in them.""" response = client.get('/') assert response.status_code == 200 assert re.search(r'Last modified: ....-..-.. ..:..:.. ...', response.data.decode()) is not None