Run the app first: uvicorn app.main:app --reload
Goal: Export leads for one day only.
Request:
curl -o single_day.csv "http://127.0.0.1:8000/export/leads.csv?start_date=2025-02-15&end_date=2025-02-15"Expected:
- Status:
200 OK - File
single_day.csvis downloaded. - Headers:
Content-Type: text/csv; charset=utf-8,Content-Disposition: attachment; filename="leads_export_YYYYMMDD.csv",Cache-Control: no-store - CSV has header row:
id,email,status,created_at - Data rows only include leads where
created_at >= 2025-02-15 00:00:00andcreated_at < 2025-02-16 00:00:00(single day).
Goal: Export leads over a date range.
Request:
curl -o multi_day.csv "http://127.0.0.1:8000/export/leads.csv?start_date=2025-02-01&end_date=2025-03-01"Expected:
- Status:
200 OK - File
multi_day.csvis downloaded. - Rows include leads with
created_atfrom 2025-02-01 00:00:00 up to (but not including) 2025-03-02 00:00:00 (i.e. through end of 2025-03-01).
Goal: Invalid date format returns 422 Unprocessable Entity.
Request:
curl -v "http://127.0.0.1:8000/export/leads.csv?start_date=2025-13-01&end_date=2025-03-01"Expected:
- Status:
422 Unprocessable Entity - Response body includes error detail (e.g. invalid date format or validation error).
Optional: Test with end_date=not-a-date or start_date=02-01-2025 and confirm 422.