added logging

This commit is contained in:
2026-07-17 19:57:08 +02:00
parent 64f1993a84
commit d9325fce98
4 changed files with 73 additions and 6 deletions
+15 -1
View File
@@ -1,6 +1,7 @@
import tempfile
from pathlib import Path
from flask_fatima import create_app
from flask_fatima import create_app, log_database_summary
URL_PREFIX = "/fatima"
@@ -30,6 +31,19 @@ def test_calendar_requires_login():
assert response.headers["Location"].endswith(url("/login"))
def test_database_summary_is_appended_to_log(capsys):
test_client = client()
with tempfile.TemporaryDirectory() as directory:
log_path = Path(directory) / "fatima.log"
log_database_summary(test_client.application.config["DATABASE"], log_path)
logged = log_path.read_text(encoding="utf-8")
assert "Fatima database:" in logged
assert f"path={test_client.application.config['DATABASE']}" in logged
assert "amounts=0 | statuses=0 | recorded_dates=0" in logged
assert "Fatima database:" in capsys.readouterr().out
def test_prefix_applies_to_generated_links_and_unprefixed_routes_are_rejected():
test_client = client()
test_client.post(url("/login"), data={"username": "user", "password": "pass"})