Skip to content

Commit fedc4ef

Browse files
committed
test: cover malformed export responses
1 parent b252ad6 commit fedc4ef

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎tests/test_http.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,38 @@ def respond(request: Request, index: int) -> Reply:
16431643
assert caught.value.status == 404
16441644

16451645

1646+
@MODES
1647+
async def test_malformed_export_response_raises_invalid_response(mode: str) -> None:
1648+
def respond(request: Request, index: int) -> Reply:
1649+
assert request.path.startswith(
1650+
f"/api/v1/organizations/{ORG}/exports/findings?"
1651+
)
1652+
return Reply(
1653+
body=b'{"dataset_version": 1, "claim": ',
1654+
headers={
1655+
"Content-Type": "application/x-ndjson",
1656+
"X-Proofline-Export-Version": "1",
1657+
"X-Proofline-Export-Settled-Until": "2026-10-25T00:00:00Z",
1658+
},
1659+
)
1660+
1661+
with Server(respond) as server:
1662+
async with session(mode, server.url) as client:
1663+
with pytest.raises(ProoflineError) as raised:
1664+
await call(
1665+
client,
1666+
"export_reviews",
1667+
ORG,
1668+
"findings",
1669+
from_time="2026-10-01T00:00:00Z",
1670+
to_time="2026-10-25T00:00:00Z",
1671+
format="ndjson",
1672+
)
1673+
1674+
assert raised.value.status == 200
1675+
assert raised.value.type == "urn:proofline:sdk:invalid-response"
1676+
1677+
16461678
@MODES
16471679
@pytest.mark.parametrize("format", ["csv", "ndjson"])
16481680
async def test_review_export_retains_every_recorded_kind(mode: str, format: str) -> None:

0 commit comments

Comments
 (0)