"""Unit tests for Store ranking helpers.""" from __future__ import annotations from pathlib import Path from stork.db import Store def test_store_ranks_by_score_then_alpha(tmp_path: Path) -> None: store = Store(tmp_path / "t.sqlite3", bootstrap_invite="unit-invite") board_id = store.list_boards()[0]["id"] a = store.add_name(board_id, "c1", "Zed", "x") store.add_name(board_id, "c1", "Ann", "x") c = store.add_name(board_id, "c1", "Bo", "x") store.vote(a["id"], "v1", "A", 1, board_id=board_id) store.vote(c["id"], "v1", "A", 1, board_id=board_id) store.vote(c["id"], "v2", "B", 1, board_id=board_id) ranked = store.list_names(board_id, "c1") assert [n["spelling"] for n in ranked] == ["Bo", "Zed", "Ann"] store.close()