feat(backend): add GET /api/claims with filter/sort/pagination
This commit is contained in:
@@ -81,3 +81,47 @@ def test_get_batch_by_id_returns_full_result(seeded_store):
|
||||
def test_get_batch_404_when_missing(client: TestClient):
|
||||
resp = client.get("/api/batches/does-not-exist")
|
||||
assert resp.status_code == 404
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# /api/claims
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
|
||||
def test_claims_returns_empty_list_when_no_parses(client: TestClient):
|
||||
resp = client.get("/api/claims")
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert body["items"] == []
|
||||
assert body["total"] == 0
|
||||
|
||||
|
||||
def test_claims_filters_by_status_submitted(seeded_store):
|
||||
resp = seeded_store.get("/api/claims?status=submitted")
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert all(c["status"] == "submitted" for c in body["items"])
|
||||
assert body["total"] >= 1
|
||||
|
||||
|
||||
def test_claims_filters_by_batch_id(seeded_store):
|
||||
bid = seeded_store.get("/api/batches").json()["items"][0]["id"]
|
||||
resp = seeded_store.get(f"/api/claims?batch_id={bid}")
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert all(c["batchId"] == bid for c in body["items"])
|
||||
|
||||
|
||||
def test_claims_sorts_by_billed_amount_desc(seeded_store):
|
||||
resp = seeded_store.get("/api/claims?sort=billedAmount&order=desc")
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
amounts = [c["billedAmount"] for c in body["items"]]
|
||||
assert amounts == sorted(amounts, reverse=True)
|
||||
|
||||
|
||||
def test_claims_pagination_limit_offset(seeded_store):
|
||||
resp1 = seeded_store.get("/api/claims?limit=1&offset=0")
|
||||
body1 = resp1.json()
|
||||
assert body1["returned"] == 1
|
||||
assert body1["has_more"] is True
|
||||
|
||||
Reference in New Issue
Block a user