From 845739eb802e01c19d9b9d22a96b8d49233821cd Mon Sep 17 00:00:00 2001 From: Johannes Thumshirn Date: Mon, 8 Mar 2021 14:28:14 +0100 Subject: [PATCH 1/2] tests: test generation of dynamic pages Test the generation of routes from the markdown input files stored under pages. Currently only the routing is tested, not the contents of the files. Signed-off-by: Johannes Thumshirn --- tests/conftest.py | 13 +++++++++++++ tests/test_page_generation.py | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/conftest.py create mode 100644 tests/test_page_generation.py 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_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 From 28dbeab4639aa6dfdce6061fce7f50a5924022c2 Mon Sep 17 00:00:00 2001 From: Johannes Thumshirn Date: Mon, 8 Mar 2021 14:34:58 +0100 Subject: [PATCH 2/2] tests: test routing of index For sake of completeness test the presence of '/' and '/index.html' as well. Signed-off-by: Johannes Thumshirn --- tests/test_index.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/test_index.py 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