This commit is contained in:
@@ -138,6 +138,7 @@ async def test_work_order_completion_creates_vehicle_records_and_updates_costs(
|
||||
headers=auth_headers,
|
||||
json={
|
||||
"title": "Engine oil",
|
||||
"category": "engine_oil",
|
||||
"product_type": "engine_oil",
|
||||
"quantity": 4,
|
||||
"unit": "l",
|
||||
@@ -210,6 +211,8 @@ async def test_work_order_completion_creates_vehicle_records_and_updates_costs(
|
||||
assert len(expenses.json()) == 1
|
||||
assert expenses.json()[0]["total_cost"] == "130.00"
|
||||
assert refreshed.json()["current_odometer"] == 10150
|
||||
assert refreshed.json()["engine_oil_type"] == "5W-30"
|
||||
assert refreshed.json()["engine_oil_volume_l"] == "4.00"
|
||||
assert stats.json()["total_cost"] == "130.00"
|
||||
|
||||
cannot_edit = await client.patch(
|
||||
|
||||
@@ -203,6 +203,75 @@ async def test_customer_booking_lifecycle_capacity_calendar_work_order_and_notif
|
||||
|
||||
my_appointments = await client.get("/api/appointments/my", headers=other_auth_headers)
|
||||
assert my_appointments.json()[0]["linked_work_order_id"] == work_order.json()["id"]
|
||||
owner_delete_converted = await client.delete(f"/api/appointments/{appointment['id']}", headers=other_auth_headers)
|
||||
sto_delete_converted = await client.delete(f"/api/sto/appointments/{appointment['id']}", headers=auth_headers)
|
||||
assert owner_delete_converted.status_code == 409
|
||||
assert sto_delete_converted.status_code == 409
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_appointments_can_be_deleted_by_owner_or_sto_before_work_order(
|
||||
client, auth_headers, other_auth_headers, admin_auth_headers, internal_headers
|
||||
) -> None:
|
||||
center = await create_verified_center(client, auth_headers, admin_auth_headers, internal_headers, city="Delete Booking")
|
||||
workday = next_weekday(2)
|
||||
await client.post(
|
||||
"/api/sto/settings/booking",
|
||||
headers=auth_headers,
|
||||
json={
|
||||
"service_center_id": center["id"],
|
||||
"working_days": [0, 1, 2, 3, 4],
|
||||
"open_time": "09:00:00",
|
||||
"close_time": "18:00:00",
|
||||
"slot_duration_minutes": 60,
|
||||
"max_parallel_bookings": 1,
|
||||
"accepts_online_booking": True,
|
||||
},
|
||||
)
|
||||
vehicle = (
|
||||
await client.post(
|
||||
"/api/my/vehicles",
|
||||
headers=other_auth_headers,
|
||||
json={"name": "Delete booking car", "current_odometer": 12000},
|
||||
)
|
||||
).json()
|
||||
|
||||
owner_deleted = (
|
||||
await client.post(
|
||||
"/api/appointments",
|
||||
headers=other_auth_headers,
|
||||
json={
|
||||
"service_center_id": center["id"],
|
||||
"vehicle_id": vehicle["id"],
|
||||
"service_type": "diagnostics",
|
||||
"service_name": "Diagnostics",
|
||||
"requested_start_at": datetime.combine(workday, time(10, 0), tzinfo=UTC).isoformat(),
|
||||
"estimated_duration_minutes": 60,
|
||||
},
|
||||
)
|
||||
).json()
|
||||
deleted_by_owner = await client.delete(f"/api/appointments/{owner_deleted['id']}", headers=other_auth_headers)
|
||||
assert deleted_by_owner.status_code == 204
|
||||
|
||||
sto_deleted = (
|
||||
await client.post(
|
||||
"/api/appointments",
|
||||
headers=other_auth_headers,
|
||||
json={
|
||||
"service_center_id": center["id"],
|
||||
"vehicle_id": vehicle["id"],
|
||||
"service_type": "diagnostics",
|
||||
"service_name": "Diagnostics",
|
||||
"requested_start_at": datetime.combine(workday, time(11, 0), tzinfo=UTC).isoformat(),
|
||||
"estimated_duration_minutes": 60,
|
||||
},
|
||||
)
|
||||
).json()
|
||||
deleted_by_sto = await client.delete(f"/api/sto/appointments/{sto_deleted['id']}", headers=auth_headers)
|
||||
assert deleted_by_sto.status_code == 204
|
||||
|
||||
my_appointments = await client.get("/api/appointments/my", headers=other_auth_headers)
|
||||
assert {item["id"] for item in my_appointments.json()}.isdisjoint({owner_deleted["id"], sto_deleted["id"]})
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user