first steps towards testing: added app fixture and first test function

This commit is contained in:
eclipse 2025-07-16 21:32:34 +02:00
parent dfe728fdc8
commit a607b8c4f3
2 changed files with 32 additions and 0 deletions

29
tests/conftest.py Normal file
View File

@ -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()

3
tests/unit/test_home.py Normal file
View File

@ -0,0 +1,3 @@
def test_request_home_startpage(client):
response = client.get("/")
assert response.data.startswith(b"<!DOCTYPE html>\n")