61 lines
1.1 KiB
Python
61 lines
1.1 KiB
Python
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()
|