Skip to content

Commit 77499e6

Browse files
committed
test(tui): update _auto_update parity test for no-toast path
1 parent 218f0aa commit 77499e6

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

tests/ui_and_conv/test_native_update_parity.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from __future__ import annotations
1010

1111
import os
12+
import time
1213
from types import SimpleNamespace
1314
from typing import cast
1415

@@ -86,25 +87,25 @@ def test_windows_source_checkout_keeps_python_upgrade_command(monkeypatch):
8687
]
8788

8889

89-
async def test_shell_auto_update_toast_shows_new_version_immediately(monkeypatch):
90+
async def test_shell_auto_update_refreshes_persistent_notice(monkeypatch):
9091
import pythinker_code.ui.shell as shell_mod
9192

9293
async def fake_refresh():
9394
return update.UpdateResult.UPDATE_AVAILABLE
9495

95-
toast_calls: list[tuple[str, dict[str, object]]] = []
9696
invalidated: list[bool] = []
9797

98-
def fake_toast(message: str, **kwargs):
99-
toast_calls.append((message, kwargs))
100-
10198
shell = shell_mod.Shell.__new__(shell_mod.Shell)
102-
# SimpleNamespace stand-in for the CustomPromptSession; only invalidate()
103-
# is exercised by _auto_update().
99+
shell._update_notice_cache = (time.monotonic(), "stale") # type: ignore[attr-defined]
104100
shell._prompt_session = SimpleNamespace( # type: ignore[assignment]
105101
invalidate=lambda: invalidated.append(True)
106102
)
107103

104+
toast_calls: list[tuple[str, dict[str, object]]] = []
105+
106+
def fake_toast(message: str, **kwargs):
107+
toast_calls.append((message, kwargs))
108+
108109
monkeypatch.setattr(shell_mod, "refresh_update_cache_if_due", fake_refresh)
109110
monkeypatch.setattr(
110111
shell_mod,
@@ -115,18 +116,9 @@ def fake_toast(message: str, **kwargs):
115116

116117
await shell_mod.Shell._auto_update(shell)
117118

118-
assert toast_calls == [
119-
(
120-
"Update available: 0.19.0 → 0.21.0. Run /update to install.",
121-
{
122-
"topic": "update",
123-
"duration": 30.0,
124-
"immediate": True,
125-
"style": "fg:ansibrightyellow bold",
126-
},
127-
)
128-
]
119+
assert toast_calls == []
129120
assert invalidated == [True]
121+
assert shell._update_notice_cache == (0.0, None) # type: ignore[attr-defined]
130122

131123

132124
def test_windows_installer_launches_signed_inno_directly(monkeypatch, tmp_path):

0 commit comments

Comments
 (0)