diff --git a/tests/python/test_findings.py b/tests/python/test_findings.py index f940eb57..f757f9c5 100644 --- a/tests/python/test_findings.py +++ b/tests/python/test_findings.py @@ -270,7 +270,15 @@ def test_an_unanswered_question_is_refused(paths: tuple[Path, Path]) -> None: assert not paths[0].exists() -@pytest.mark.parametrize("words", ["Change it", "No", "Yes, but say three delays"]) +def test_a_click_on_the_recommended_yes_counts_as_agreement(paths: tuple[Path, Path]) -> None: + """The question box records a click on the recommended option with this suffix.""" + by_question(paths, asked(paths, f'May the ledger say: "{LINE}"?', "Yes (Recommended)")) + assert [e["text"] for e in entries(paths)] == [LINE] + + +@pytest.mark.parametrize( + "words", ["Change it", "No", "Yes, but say three delays", "No (Recommended)", "(Recommended)"] +) def test_an_answer_other_than_agreement_is_refused(paths: tuple[Path, Path], words: str) -> None: qid = asked(paths, f'May the ledger say: "{LINE}"?', words) with pytest.raises(findings.RefusedError, match="agree"): diff --git a/tools/findings.py b/tools/findings.py index 970b01b3..f347feef 100644 --- a/tools/findings.py +++ b/tools/findings.py @@ -14,10 +14,10 @@ `add` and `replace` need Ola's agreement to the wording: `--ola`, words found in this session's transcript as `brief.py --ola` finds them, or `--question `, a question `questions.py` stored whose text holds the line and whose answer is -one of `AGREE`. Each `search` appends its time and -words to `/findings-searches.jsonl`, untracked; `questions.py -add` and design or probe briefs (`brief.py`) refuse through `unsearched` until -a search ran in the last hour. Standard library only. +one of `AGREE`, alone or with the box's `RECOMMENDED` suffix. Each `search` +appends its time and words to `/findings-searches.jsonl`, +untracked; `questions.py add` and design or probe briefs (`brief.py`) refuse +through `unsearched` until a search ran in the last hour. Standard library only. """ from __future__ import annotations @@ -41,6 +41,8 @@ WINDOW = timedelta(hours=1) #: Chosen: whole answers that agree; anything else, "Yes, but ..." too, is refused. AGREE = {"yes", "agree", "agreed", "ok", "approve", "approved"} +#: The question box's suffix on a click of the recommended option, as in "Yes (Recommended)". +RECOMMENDED = " (Recommended)" class RefusedError(Exception): @@ -84,7 +86,7 @@ def _answered(args: argparse.Namespace, store: Path) -> str: raise RefusedError(f"there is no question {qid}") if record["state"] != "answered": raise RefusedError(f"question {qid} is not answered") - if record["words"].strip(" .!").casefold() not in AGREE: + if record["words"].removesuffix(RECOMMENDED).strip(" .!").casefold() not in AGREE: raise RefusedError(f'Ola did not agree to question {qid}: "{record["words"]}"') if " ".join(args.text.split()) not in " ".join(record["text"].split()): raise RefusedError(f"question {qid} does not hold this line")