Hand-added votes per question (paper, show of hands): counted in the turnout and shown hatched orange at the end of each result bar, kept apart from phone ballots

This commit is contained in:
2026-11-17 14:42:54 +01:00
parent ad6c3c6f57
commit c924107f1d
11 changed files with 164 additions and 32 deletions
+25
View File
@@ -708,3 +708,28 @@ def test_trial_enrolls_then_expires(server):
assert con.execute("SELECT COUNT(*) FROM voters WHERE poll_id=?", (p["id"],)).fetchone()[0] == 0
con.close()
assert httpx.get(f"{server['base']}/screen/{p['id']}", verify=server["verify"]).status_code == 404
def test_hand_added_votes(server):
p = create(server, vote_scans=0)
admin(server, p, "PATCH", "", json={"enrollment_open": True})
async def run():
async with projector(server, p) as next_token:
a = await enroll(server, p, next_token)
qid = admin(server, p, "POST", "/questions", json={"text": "Q", "options": ["A", "B"], "open": True}).json()["id"]
assert (await a.post(f"/api/v/{p['id']}/vote", json={"question_id": qid, "choices": [0]})).status_code == 200
# paper ballots counted at the desk
assert admin(server, p, "POST", f"/questions/{qid}/extra", json={"counts": [2, 5], "blank": 1}).status_code == 200
q = admin(server, p, "GET", "").json()["questions"][0]
assert q["extra_ballots"] == 8 and q["extra"] == {"counts": [2, 5], "blank": 1, "ballots": 8}
assert "results" not in q # still open: no tally, hand-added or not
assert admin(server, p, "POST", f"/questions/{qid}/extra", json={"counts": [1]}).status_code == 400
assert admin(server, p, "POST", f"/questions/{qid}/extra", json={"counts": [-1, 0]}).status_code == 400
admin(server, p, "POST", f"/questions/{qid}/close")
r = admin(server, p, "GET", "").json()["questions"][0]["results"]
# phone ballots and hand-added ones stay apart
assert r["counts"] == [1, 0] and r["ballots"] == 1 and r["extra"]["counts"] == [2, 5]
await a.aclose()
asyncio.run(run())