From a607b8c4f3c8e62d00dd99ae6ee5105b4cc581ac Mon Sep 17 00:00:00 2001 From: eclipse Date: Wed, 16 Jul 2025 21:32:34 +0200 Subject: [PATCH] first steps towards testing: added app fixture and first test function --- tests/conftest.py | 29 +++++++++++++++++++++++++++++ tests/unit/test_home.py | 3 +++ 2 files changed, 32 insertions(+) create mode 100644 tests/conftest.py create mode 100644 tests/unit/test_home.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e1ffdf8 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,29 @@ +import pytest +from the_works import create_app + +TEST_DATABASE_URI = "sqlite:///:memory:" + +@pytest.fixture() +def app(): + test_config = { + "ENV": "Testing", + "SQLALCHEMY_DATABASE_URI": TEST_DATABASE_URI, + "TESTING": True + } + app = create_app(test_config) + + # other setup can go here + + yield app + + # clean up / reset resources here + + +@pytest.fixture() +def client(app): + return app.test_client() + + +@pytest.fixture() +def runner(app): + return app.test_cli_runner() \ No newline at end of file diff --git a/tests/unit/test_home.py b/tests/unit/test_home.py new file mode 100644 index 0000000..268d5a5 --- /dev/null +++ b/tests/unit/test_home.py @@ -0,0 +1,3 @@ +def test_request_home_startpage(client): + response = client.get("/") + assert response.data.startswith(b"\n") \ No newline at end of file