test: select an available vehicle for booking creation

This commit is contained in:
NuklearRabbit
2026-08-10 02:54:50 +02:00
parent b2e1ae7f17
commit 3f13912739
+8 -3
View File
@@ -32,17 +32,22 @@ def test_create_booking_rejects_overlap_and_audits_valid_booking(ops_client):
}, },
) )
assert conflict.status_code == 409 assert conflict.status_code == 409
available_vehicle = ops_client.get(
"/api/v1/vehicles", params={"status": "available"}
).json()[0]["public_ref"]
created = ops_client.post( created = ops_client.post(
"/api/v1/bookings", "/api/v1/bookings",
json={ json={
"customer_ref": "CUS-0001", "vehicle_ref": "MO-001", "customer_ref": "CUS-0001",
"starts_at": "2030-09-01T10:00:00Z", "ends_at": "2030-09-02T12:00:00Z", "vehicle_ref": available_vehicle,
"starts_at": "2030-09-01T10:00:00Z",
"ends_at": "2030-09-02T12:00:00Z",
}, },
) )
assert created.status_code == 201 assert created.status_code == 201
body = created.json() body = created.json()
assert body["status"] == "reserved" assert body["status"] == "reserved"
assert body["vehicle_ref"] == "MO-001" assert body["vehicle_ref"] == available_vehicle
def test_get_booking_detail(ops_client): def test_get_booking_detail(ops_client):