""" End-to-end test for Expense creation flow. Uses the authenticated_client fixture to test POST /api/v1/expenses/add endpoint. """ import pytest import httpx from datetime import date @pytest.mark.asyncio async def test_expense_creation(authenticated_client: httpx.AsyncClient, setup_vehicle): """ Test that a user can add an expense (fuel/service) to an asset. Uses the setup_vehicle fixture to get a valid asset_id. """ asset_id = setup_vehicle # Now add an expense for this asset expense_payload = { "asset_id": str(asset_id), # must be string "category": "fuel", # or "service", "insurance", etc. "amount": 15000.0, "date": str(date.today()), # YYYY-MM-DD } response = await authenticated_client.post( "/api/v1/expenses/add", json=expense_payload ) # Assert success assert response.status_code == 200, f"Unexpected status: {response.status_code}, response: {response.text}" data = response.json() assert data["status"] == "success" print(f"✅ Expense added for asset {asset_id}")