diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..72f47bb --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0 +import pytest + +from app import app as flask_app + +@pytest.fixture +def app(): + yield flask_app + + +@pytest.fixture +def client(app): + return app.test_client() diff --git a/tests/test_index.py b/tests/test_index.py new file mode 100644 index 0000000..1ab87a7 --- /dev/null +++ b/tests/test_index.py @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-3.0 +import os + +def test_index_html(app, client): + res = client.get('/index.html') + assert res.status_code == 200 + + +def test_index_slash(app, client): + res = client.get('/') + assert res.status_code == 200 diff --git a/tests/test_page_generation.py b/tests/test_page_generation.py new file mode 100644 index 0000000..8718111 --- /dev/null +++ b/tests/test_page_generation.py @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0 +import os + +def test_index(app, client): + for f in os.listdir('pages'): + if not f.endswith('.md'): + continue + + dynamic_file = f.split('.', 1)[0] + page = "/" + dynamic_file + ".html" + print("Checking presence of: ", page) + res = client.get(page) + assert res.status_code == 200 diff --git a/tests/test_static_pages.py b/tests/test_static_pages.py index f5b59b2..8ecab49 100644 --- a/tests/test_static_pages.py +++ b/tests/test_static_pages.py @@ -7,17 +7,14 @@ import sys import pytest import pytest_cov.embed -def test_static_pages(): +def test_static_pages(app, client): for f in os.listdir('templates'): if f == "template.html" or f == "page.html": continue static_file = f.split('.',1)[0] - - print("Checking presence of method: ", static_file) - try: - method = getattr(app, static_file) - assert True - except NotImplementedError: - assert False + page = "/" + static_file + ".html" + print("Checking presence of: ", page) + res = client.get(page) + assert res.status_code == 200