feat: initial Flask project setup with factory pattern

This commit is contained in:
2026-03-11 16:23:39 +01:00
parent 3b3a5e4187
commit 41679d1861
13 changed files with 119 additions and 0 deletions

60
tests/conftest.py Normal file
View File

@@ -0,0 +1,60 @@
import pytest
from app import create_app, db as _db
@pytest.fixture
def app(tmp_path):
config_path = tmp_path / "config.toml"
config_path.write_text("""
[vehicles.voiture]
name = "Peugeot 308"
fuel = "diesel"
co2_per_km = 142
cv = 5
[vehicles.velo]
name = "Vélo"
fuel = "none"
co2_per_km = 0
[journeys.voiture_seule]
name = "Voiture seule"
distances = { voiture = 25 }
[journeys.voiture_velo]
name = "Voiture + Vélo"
distances = { voiture = 14, velo = 8 }
[journeys.velo_seul]
name = "Vélo seul"
distances = { velo = 24 }
[[bareme_kilometrique.2025.cv_5.tranches]]
km_max = 3000
taux = 0.548
forfait = 0
[[bareme_kilometrique.2025.cv_5.tranches]]
km_max = 6000
taux = 0.316
forfait = 699
[[bareme_kilometrique.2025.cv_5.tranches]]
km_max = 0
taux = 0.364
forfait = 0
""", encoding="utf-8")
application = create_app(config_path=str(config_path))
application.config["TESTING"] = True
application.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
with application.app_context():
_db.create_all()
yield application
_db.drop_all()
@pytest.fixture
def client(app):
return app.test_client()