import pytest from sqlalchemy import text pytestmark = pytest.mark.anyio API = "/api/v1" async def test_am_can_list_only_approval_csv_tables_and_download_approval_pdf(client, auth, db): await db.execute( text( ''' CREATE TABLE IF NOT EXISTS "fare_chart" ( id UUID PRIMARY KEY, source_row_number INTEGER, name TEXT, headquarter TEXT, serial_no TEXT, report_date TEXT, from_location TEXT, to_location TEXT, kilometers_km TEXT, owner_user_id UUID ) ''' ) ) await db.commit() resp = await client.get(f"{API}/csv-data/tables", headers=auth["am1"]) assert resp.status_code == 200, resp.text table_names = {item["name"] for item in resp.json()} assert table_names == {"standard_tour_plan", "tour_plan", "fare_chart", "expense_statement"} assert "daily_call_report_csv" not in table_names pdf = await client.get(f"{API}/csv-data/fare_chart/pdf", headers=auth["am1"]) assert pdf.status_code == 200, pdf.text assert pdf.headers["content-type"].startswith("application/pdf")