From 96694e2de493d777e12b79eccd4fb024079af067 Mon Sep 17 00:00:00 2001 From: Antoine Van Elstraete Date: Wed, 11 Mar 2026 17:53:00 +0100 Subject: [PATCH] test: update integration tests for motor vehicle selection --- tests/test_routes.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/test_routes.py b/tests/test_routes.py index 3f56cac..ed114fc 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -20,7 +20,8 @@ def test_create_entry(client, app): response = client.post("/entries/new", data={ "date": "2025-06-02", "day_type": "WORK", - "journey_profile_id": "voiture_seule", + "journey_profile_id": "moteur_seul", + "motor_vehicle_id": "familiale", "start_time": ["09:00"], "end_time": ["17:45"], "comment": "", @@ -34,6 +35,7 @@ def test_create_entry(client, app): assert entry is not None assert entry.day_type == "WORK" assert len(entry.time_slots) == 1 + assert entry.motor_vehicle_id == "familiale" def test_entry_list(client, app): @@ -68,3 +70,24 @@ def test_delete_entry(client, app): sa.select(WorkEntry).where(WorkEntry.id == entry_id) ) assert deleted is None + + +def test_create_entry_velo_no_motor_vehicle(client, app): + """Un trajet vélo seul ne doit pas enregistrer de motor_vehicle_id.""" + response = client.post("/entries/new", data={ + "date": "2025-06-10", + "day_type": "WORK", + "journey_profile_id": "velo_seul", + "motor_vehicle_id": "", + "start_time": ["08:30"], + "end_time": ["17:00"], + "comment": "", + }, follow_redirects=True) + assert response.status_code == 200 + + with app.app_context(): + entry = db.session.scalar( + sa.select(WorkEntry).where(WorkEntry.date == date(2025, 6, 10)) + ) + assert entry is not None + assert entry.motor_vehicle_id is None