Scripted UI surface recording ``select`` calls (``/effort`` only uses select).
| 60 | # Fakes / fixtures |
| 61 | # --------------------------------------------------------------------------- # |
| 62 | class FakeUIHost: |
| 63 | """Scripted UI surface recording ``select`` calls (``/effort`` only uses select).""" |
| 64 | |
| 65 | def __init__(self, *, pick: str | None = None, text: str | None = None) -> None: |
| 66 | self._pick = pick |
| 67 | self._text = text |
| 68 | self.select_calls: list[dict] = [] |
| 69 | self.prompt_calls: list[dict] = [] |
| 70 | self.display_calls: list[tuple[str, str]] = [] |
| 71 | |
| 72 | async def select(self, title, options, *, current=None): |
| 73 | self.select_calls.append( |
| 74 | { |
| 75 | "title": title, |
| 76 | "values": [o.value for o in options], |
| 77 | "labels": [o.label for o in options], |
| 78 | "descriptions": [o.description for o in options], |
| 79 | "current": current, |
| 80 | } |
| 81 | ) |
| 82 | return self._pick |
| 83 | |
| 84 | async def prompt_text(self, title, *, default="", placeholder=None): |
| 85 | self.prompt_calls.append( |
| 86 | {"title": title, "default": default, "placeholder": placeholder} |
| 87 | ) |
| 88 | return self._text |
| 89 | |
| 90 | async def display(self, title, body): |
| 91 | self.display_calls.append((title, body)) |
| 92 | |
| 93 | |
| 94 | @pytest.fixture |
no outgoing calls