Files
Aegis/backend/tests/test_professional_reports_router.py
Kitos 6ab950ec42 feat(reports): add quarterly and technique download routes [FASE-2.4]
Expose GET endpoints for quarterly-summary and technique reports with PDF, DOCX, and HTML formats.
2026-05-18 14:00:46 +02:00

43 lines
1.2 KiB
Python

"""Professional reports router tests (FASE-2.4)."""
from unittest.mock import patch
from app.models.campaign import Campaign
@patch("app.services.report_generation_service.generate_purple_campaign_report")
def test_purple_campaign_pdf_download(mock_gen, client, auth_headers, db):
mock_gen.return_value = __file__ # existing file for FileResponse
campaign = Campaign(name="Export Camp", status="active")
db.add(campaign)
db.commit()
r = client.get(
f"/api/v1/reports/generate/purple-campaign/{campaign.id}",
params={"format": "pdf"},
headers=auth_headers,
)
assert r.status_code == 200
assert r.headers["content-type"] == "application/pdf"
@patch("app.services.report_generation_service.generate_coverage_report")
def test_coverage_summary_html(mock_gen, client, auth_headers):
import tempfile
import os
fd, path = tempfile.mkstemp(suffix=".html")
os.write(fd, b"<html><body>ok</body></html>")
os.close(fd)
mock_gen.return_value = path
r = client.get(
"/api/v1/reports/generate/coverage-summary",
params={"format": "html"},
headers=auth_headers,
)
assert r.status_code == 200
assert "text/html" in r.headers["content-type"]
os.unlink(path)