diff --git a/tests/functional_tests.py b/tests/functional_tests.py new file mode 100644 index 0000000..46a1c1d --- /dev/null +++ b/tests/functional_tests.py @@ -0,0 +1,37 @@ +"""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_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'incorporeal.org' in response.data + assert b'

this page doesn\'t have a title!

' 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 diff --git a/tests/test_pages.py b/tests/test_pages.py index 7fe7c5b..319eaaf 100644 --- a/tests/test_pages.py +++ b/tests/test_pages.py @@ -1,6 +1,4 @@ -"""Test page views and helper methods.""" -import re - +"""Unit test helper methods.""" from incorporealcms.pages import generate_parent_navs, resolve_page_file @@ -19,41 +17,6 @@ def test_resolve_page_file_other_requests_fine(): assert resolve_page_file('foo/baz') == 'pages/foo/baz.md' -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_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'incorporeal.org' in response.data - assert b'

this page doesn\'t have a title!

' 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 - - def test_generate_page_navs_index(app): """Test that the index page has navs to the root (itself).""" with app.app_context(): diff --git a/tox.ini b/tox.ini index 67b5151..733eb3b 100644 --- a/tox.ini +++ b/tox.ini @@ -62,7 +62,10 @@ exclude = max-complexity = 10 [pytest] -python_files = tests.py test_*.py +python_files = + *_tests.py + tests.py + test_*.py [coverage:run] branch = True