fix: resolve audit report gaps across bulk imports, auth, scoping, and exports
This commit is contained in:
@@ -242,3 +242,34 @@ def test_report_exports_xlsx_and_csv(client):
|
||||
headers=mgmt_headers,
|
||||
)
|
||||
assert bad_fmt.status_code == 422
|
||||
|
||||
|
||||
def test_all_eight_reports_export_xlsx_and_csv(client):
|
||||
"""Verify that all 8 reports export cleanly as both XLSX and CSV without title/slash errors."""
|
||||
admin_headers = _auth_headers(client, "admin@poona.demo")
|
||||
|
||||
for key in ALL_REPORT_KEYS:
|
||||
# Test XLSX export
|
||||
xlsx_res = client.get(
|
||||
f"/api/reports/{key}/export?format=xlsx",
|
||||
headers=admin_headers,
|
||||
)
|
||||
assert xlsx_res.status_code == 200, f"XLSX export failed for {key}: {xlsx_res.text}"
|
||||
assert "spreadsheetml.sheet" in xlsx_res.headers["content-type"]
|
||||
assert f'filename="{key}.xlsx"' in xlsx_res.headers["content-disposition"]
|
||||
|
||||
wb = openpyxl.load_workbook(BytesIO(xlsx_res.content))
|
||||
ws = wb.active
|
||||
assert ws is not None
|
||||
assert "/" not in ws.title and "\\" not in ws.title
|
||||
assert len(ws.title) <= 31
|
||||
|
||||
# Test CSV export
|
||||
csv_res = client.get(
|
||||
f"/api/reports/{key}/export?format=csv",
|
||||
headers=admin_headers,
|
||||
)
|
||||
assert csv_res.status_code == 200, f"CSV export failed for {key}: {csv_res.text}"
|
||||
assert "text/csv" in csv_res.headers["content-type"]
|
||||
assert f'filename="{key}.csv"' in csv_res.headers["content-disposition"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user