diff --git a/tests/test_pack_command.py b/tests/test_pack_command.py index f6752e2..1e413c6 100644 --- a/tests/test_pack_command.py +++ b/tests/test_pack_command.py @@ -136,13 +136,25 @@ async def test_a_name_nobody_has_gets_the_same_answer( async def test_a_choice_lands_on_the_reading_that_has_a_photo( tmp_path: Path, transport: FakeTransport, store: Store, config: Config ) -> None: - """p2 has no photo of their own, so "either of them" must not fail.""" - pack = load( - pack_fixture.build(tmp_path / "pack", tags={"gamma.png": ["p3"], "both.png": ["p1", "p2"]}) - ) + """p2 has no photo at all, so "either of them" must land on p3 every time. + + Deterministic on purpose. Asserting that a random choice eventually + produces both readings is a test that fails one run in sixteen, and this + repo has already shipped one bug because a random API was believed after + a single call. + """ + pack = load(pack_fixture.build(tmp_path / "pack", tags={"gamma.png": ["p3"]})) for _ in range(5): await _run(pack, transport, store, config, "!ktokolwiek") - assert {message.filename for message in transport.sent} == {"gamma.png", "both.png"} + assert [message.filename for message in transport.sent] == ["gamma.png"] * 5 + + +async def test_a_choice_with_nothing_behind_either_reading_is_answered( + tmp_path: Path, transport: FakeTransport, store: Store, config: Config +) -> None: + pack = load(pack_fixture.build(tmp_path / "pack", tags={"alfa.png": ["p1"]})) + await _run(pack, transport, store, config, "!ktokolwiek") + assert transport.texts == [NO_PHOTO] async def test_a_video_keeps_being_a_video( diff --git a/tool/tagger.html b/tool/tagger.html index d1ea1bd..9c30526 100644 --- a/tool/tagger.html +++ b/tool/tagger.html @@ -76,8 +76,6 @@ const api = (path, body) => fetch(path, body ? { let state = null; let at = 0; -function key(name, index) { return name || `p${index + 1}`; } - function parseSetup(text) { const people = [], combos = []; const byName = new Map(); @@ -110,8 +108,11 @@ function drawGroups(known, chosen) { box.innerHTML = ''; return; } - box.innerHTML = known.map((g, i) => `