Ship name corpus lookup/spin, nickname suggestions, significance UX, site-ideas SMTP, and remove the Logo concepts page and assets.
48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
"""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()
|
||
|
||
|
||
def test_store_significance(tmp_path: Path) -> None:
|
||
store = Store(tmp_path / "sig.sqlite3", bootstrap_invite="sig-invite")
|
||
board_id = store.list_boards()[0]["id"]
|
||
n = store.add_name(board_id, "c1", "Noa", "x", significance="Aunt Mira’s middle name")
|
||
assert n["significance"] == "Aunt Mira’s middle name"
|
||
updated = store.update_name(n["id"], significance="Family favorite", board_id=board_id)
|
||
assert updated is not None
|
||
assert updated["significance"] == "Family favorite"
|
||
store.close()
|
||
|
||
|
||
def test_store_nicknames_auto_and_edit(tmp_path: Path) -> None:
|
||
store = Store(tmp_path / "nick.sqlite3", bootstrap_invite="nick-invite")
|
||
board_id = store.list_boards()[0]["id"]
|
||
suzy = store.add_name(board_id, "c1", "Suzy", "x")
|
||
assert "Su" in suzy["nicknames"]
|
||
roza = store.add_name(board_id, "c1", "Roza", "x")
|
||
assert "Ro" in roza["nicknames"]
|
||
edited = store.update_name(suzy["id"], nicknames="Zu, Zuzu", board_id=board_id)
|
||
assert edited is not None
|
||
assert edited["nicknames"] == "Zu, Zuzu"
|
||
odd = store.add_name(board_id, "c1", "Xylophone", "x", nicknames="")
|
||
assert odd["nicknames"] == ""
|
||
store.close()
|