Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion proofline/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def decode_export(response: httpx.Response, format: ExportFormat) -> ExportPage:
try:
media = "text/csv" if format == "csv" else "application/x-ndjson"
if (
response.headers.get("content-type", "").split(";")[0].strip() != media
response.headers.get("content-type", "").split(";")[0].strip().lower() != media
or response.headers.get("x-proofline-export-version") != "1"
):
raise ValueError
Expand Down
40 changes: 40 additions & 0 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,46 @@ def respond(request: Request, index: int) -> Reply:
assert caught.value.status == 404


@MODES
@pytest.mark.parametrize(
("format", "content_type"),
[
("csv", "Text/CSV; charset=utf-8"),
("ndjson", "Application/X-NDJSON; charset=utf-8"),
],
)
async def test_export_accepts_case_insensitive_content_type(
mode: str, format: str, content_type: str
) -> None:
def respond(request: Request, index: int) -> Reply:
body = (
b"dataset_version,claim\n1,hello\n"
if format == "csv"
else b'{"dataset_version":1,"claim":"hello"}\n'
)
return Reply(
body=body,
headers={
"Content-Type": content_type,
"X-Proofline-Export-Version": "1",
"X-Proofline-Export-Settled-Until": "2026-10-25T00:00:00Z",
},
)

with Server(respond) as server:
async with session(mode, server.url) as client:
page = await call(
client,
"export_reviews",
ORG,
"findings",
format=format,
from_time="2026-10-01T00:00:00Z",
to_time="2026-10-25T00:00:00Z",
)
assert page.rows[0]["claim"] == "hello"


@MODES
@pytest.mark.parametrize("format", ["csv", "ndjson"])
async def test_review_export_retains_every_recorded_kind(mode: str, format: str) -> None:
Expand Down