accli 2.1.1__tar.gz → 2.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {accli-2.1.1 → accli-2.1.3}/PKG-INFO +2 -2
  2. {accli-2.1.1 → accli-2.1.3}/README.md +1 -1
  3. {accli-2.1.1 → accli-2.1.3}/accli/_version.py +1 -1
  4. {accli-2.1.1 → accli-2.1.3}/accli/cli.py +78 -21
  5. {accli-2.1.1 → accli-2.1.3}/accli/gui.py +3 -3
  6. {accli-2.1.1 → accli-2.1.3}/accli/setup-nfs.ps1 +18 -1
  7. {accli-2.1.1 → accli-2.1.3}/accli.egg-info/PKG-INFO +2 -2
  8. {accli-2.1.1 → accli-2.1.3}/accli.egg-info/SOURCES.txt +2 -1
  9. accli-2.1.3/tests/test_update_check.py +151 -0
  10. {accli-2.1.1 → accli-2.1.3}/LICENSE +0 -0
  11. {accli-2.1.1 → accli-2.1.3}/accli/AcceleratorJobProjectService.py +0 -0
  12. {accli-2.1.1 → accli-2.1.3}/accli/AcceleratorTaskDispatcher.py +0 -0
  13. {accli-2.1.1 → accli-2.1.3}/accli/AcceleratorTerminalCliProjectService.py +0 -0
  14. {accli-2.1.1 → accli-2.1.3}/accli/CsvRegionalTimeseriesValidator.py +0 -0
  15. {accli-2.1.1 → accli-2.1.3}/accli/__init__.py +0 -0
  16. {accli-2.1.1 → accli-2.1.3}/accli/__main__.py +0 -0
  17. {accli-2.1.1 → accli-2.1.3}/accli/cleanup-nfs.ps1 +0 -0
  18. {accli-2.1.1 → accli-2.1.3}/accli/common.py +0 -0
  19. {accli-2.1.1 → accli-2.1.3}/accli/job_views.py +0 -0
  20. {accli-2.1.1 → accli-2.1.3}/accli/log_timeline.py +0 -0
  21. {accli-2.1.1 → accli-2.1.3}/accli/mount_downloader.py +0 -0
  22. {accli-2.1.1 → accli-2.1.3}/accli/nfs_watcher.py +0 -0
  23. {accli-2.1.1 → accli-2.1.3}/accli/refresh_explorer.ps1 +0 -0
  24. {accli-2.1.1 → accli-2.1.3}/accli/token.py +0 -0
  25. {accli-2.1.1 → accli-2.1.3}/accli/version_checker.py +0 -0
  26. {accli-2.1.1 → accli-2.1.3}/accli.egg-info/dependency_links.txt +0 -0
  27. {accli-2.1.1 → accli-2.1.3}/accli.egg-info/entry_points.txt +0 -0
  28. {accli-2.1.1 → accli-2.1.3}/accli.egg-info/requires.txt +0 -0
  29. {accli-2.1.1 → accli-2.1.3}/accli.egg-info/top_level.txt +0 -0
  30. {accli-2.1.1 → accli-2.1.3}/pyproject.toml +0 -0
  31. {accli-2.1.1 → accli-2.1.3}/setup.cfg +0 -0
  32. {accli-2.1.1 → accli-2.1.3}/tests/test_jobs_commands.py +0 -0
  33. {accli-2.1.1 → accli-2.1.3}/tests/test_log_timeline.py +0 -0
  34. {accli-2.1.1 → accli-2.1.3}/tests/test_logs_command.py +0 -0
  35. {accli-2.1.1 → accli-2.1.3}/tests/test_mount_lifecycle.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accli
3
- Version: 2.1.1
3
+ Version: 2.1.3
4
4
  Summary: IIASA Accelerator Client
5
5
  Author-email: Wrufesh S <wrufesh@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -70,7 +70,7 @@ This client uses **device authentication** via Auth0.
70
70
 
71
71
  ### ✅ Requirements
72
72
 
73
- - Python >= 3.7.17
73
+ - Python >= 3.8
74
74
 
75
75
  ### 📦 Installation
76
76
 
@@ -26,7 +26,7 @@ This client uses **device authentication** via Auth0.
26
26
 
27
27
  ### ✅ Requirements
28
28
 
29
- - Python >= 3.7.17
29
+ - Python >= 3.8
30
30
 
31
31
  ### 📦 Installation
32
32
 
@@ -1,3 +1,3 @@
1
1
  # Please strictly put double quote to use this info for git tag
2
2
  # Read a developer guide for git tag command with regex
3
- VERSION = "v2.1.1"
3
+ VERSION = "v2.1.3"
@@ -36,27 +36,20 @@ ACCLI_DEBUG = os.environ.get('ACCLI_DEBUG', False)
36
36
  app = typer.Typer(
37
37
  add_completion=False,
38
38
  pretty_exceptions_show_locals=False,
39
- no_args_is_help=True,
40
39
  context_settings={"help_option_names": ["-h", "--help"]}
41
40
  )
42
41
 
43
42
 
44
- def version_callback(value: bool):
45
- if value:
46
- print(f"[bold cyan]accli version: {VERSION}[/bold cyan]")
47
- update_avail, latest = check_for_updates()
48
- if update_avail:
49
- instruction = get_upgrade_instruction()
50
- print(f"[bold yellow]🔔 A new version of accli is available: {latest} (Current: {VERSION})[/bold yellow]")
51
- print(f"[yellow]{instruction}[/yellow]\n")
52
- raise typer.Exit()
53
-
54
-
55
- @app.callback()
43
+ @app.callback(invoke_without_command=True)
56
44
  def main_callback(
45
+ ctx: typer.Context,
57
46
  version: Annotated[
58
47
  bool,
59
- typer.Option("--version", "-v", callback=version_callback, is_eager=True, help="Show the version and exit.")
48
+ typer.Option("--version", "-v", help="Show the version and exit.")
49
+ ] = False,
50
+ help: Annotated[
51
+ bool,
52
+ typer.Option("--help", "-h", help="Show this message and exit.")
60
53
  ] = False,
61
54
  ):
62
55
  update_avail, latest = check_for_updates()
@@ -65,6 +58,14 @@ def main_callback(
65
58
  print(f"[bold yellow]🔔 Update available: accli {latest} (current: {VERSION})[/bold yellow]")
66
59
  print(f"[yellow]{instruction}[/yellow]\n")
67
60
 
61
+ if version:
62
+ print(f"[bold cyan]accli version: {VERSION}[/bold cyan]")
63
+ raise typer.Exit()
64
+
65
+ if help or ctx.invoked_subcommand is None:
66
+ typer.echo(ctx.get_help())
67
+ raise typer.Exit()
68
+
68
69
 
69
70
  def get_size(path):
70
71
  size = 0
@@ -93,11 +94,6 @@ def about():
93
94
  print("[bold cyan]Feature requests & suggestions: https://github.com/iiasa/accli/issues[/bold cyan]")
94
95
  print("[bold cyan]License: The MIT License (MIT)[/bold cyan]")
95
96
  print(f"[bold cyan]Version: {VERSION}[/bold cyan]")
96
- update_avail, latest = check_for_updates()
97
- if update_avail:
98
- instruction = get_upgrade_instruction()
99
- print(f"[bold yellow]🔔 A new version of accli is available: {latest} (Current: {VERSION})[/bold yellow]")
100
- print(f"[yellow]{instruction}[/yellow]\n")
101
97
 
102
98
 
103
99
  @app.command()
@@ -1097,6 +1093,14 @@ def map_windows_network_drive(mount_point_abs, max_attempts: int) -> tuple[bool,
1097
1093
  for attempt in range(1, max_attempts + 1):
1098
1094
  cleanup_stuck_windows_mount_processes()
1099
1095
 
1096
+ # Ensure any prior accli-umount-nfs task has finished and NfsClnt is RUNNING (prevents Network Error - 1222)
1097
+ for _ in range(10):
1098
+ umount_check = subprocess.run(["schtasks", "/query", "/tn", "accli-umount-nfs"], capture_output=True, text=True, errors="replace")
1099
+ clnt_check = subprocess.run(["sc.exe", "query", "NfsClnt"], capture_output=True, text=True, errors="replace")
1100
+ if (not umount_check.stdout or "Running" not in umount_check.stdout) and (clnt_check.stdout and "RUNNING" in clnt_check.stdout):
1101
+ break
1102
+ time.sleep(0.5)
1103
+
1100
1104
  # If daemon died before or between attempts, revive it
1101
1105
  if not is_nfs_daemon_running():
1102
1106
  subprocess.run(["schtasks", "/run", "/tn", "accli-mount-nfs"], capture_output=True)
@@ -1107,7 +1111,7 @@ def map_windows_network_drive(mount_point_abs, max_attempts: int) -> tuple[bool,
1107
1111
  if res.returncode == 0:
1108
1112
  # Confirm drive is actually mounted and directory listing is populated and queryable
1109
1113
  drive_ready = False
1110
- for _ in range(30):
1114
+ for _ in range(10):
1111
1115
  try:
1112
1116
  if os.path.exists(drive_root):
1113
1117
  entries = os.listdir(drive_root)
@@ -1119,8 +1123,15 @@ def map_windows_network_drive(mount_point_abs, max_attempts: int) -> tuple[bool,
1119
1123
  time.sleep(0.5)
1120
1124
  if not drive_ready:
1121
1125
  last_err = f"mount.exe reported success but drive {drive_root} was empty or not accessible"
1122
- # Clean up the stale mount connection so next attempt can remount fresh
1126
+ # Clean up the stale mount connection and reset NfsRdr kernel cache so next attempt can remount fresh
1123
1127
  subprocess.run(["net", "use", target_str, "/delete", "/y"], capture_output=True)
1128
+ subprocess.run(["schtasks", "/run", "/tn", "accli-umount-nfs"], capture_output=True)
1129
+ for _ in range(16):
1130
+ time.sleep(0.5)
1131
+ umount_check = subprocess.run(["schtasks", "/query", "/tn", "accli-umount-nfs"], capture_output=True, text=True, errors="replace")
1132
+ clnt_check = subprocess.run(["sc.exe", "query", "NfsClnt"], capture_output=True, text=True, errors="replace")
1133
+ if (not umount_check.stdout or "Running" not in umount_check.stdout) and (clnt_check.stdout and "RUNNING" in clnt_check.stdout):
1134
+ break
1124
1135
  else:
1125
1136
  last_err = (res.stderr or res.stdout or "").strip()
1126
1137
  if "85" in last_err or "already in use" in last_err.lower():
@@ -1231,6 +1242,42 @@ def enable_windows_nfs_features():
1231
1242
  reg_ok = reg_ok and anon_ok and cache_ok
1232
1243
 
1233
1244
  if nfs_ok and reg_ok and task_ok:
1245
+ # Ensure run-umount-helper.ps1 includes fast nfsclnt termination and NfsRdr/NfsClnt kernel cache flush
1246
+ try:
1247
+ umount_helper = Path("C:/ProgramData/accli/run-umount-helper.ps1")
1248
+ if umount_helper.is_file():
1249
+ content = umount_helper.read_text(encoding="utf-8", errors="ignore")
1250
+ if 'Stop-Process -Name "nfsclnt"' not in content:
1251
+ umount_helper.write_text(
1252
+ 'try {\n'
1253
+ ' if (Get-Command Stop-ScheduledTask -ErrorAction SilentlyContinue) {\n'
1254
+ ' Stop-ScheduledTask -TaskName "accli-mount-nfs" -ErrorAction SilentlyContinue | Out-Null\n'
1255
+ ' } else {\n'
1256
+ ' schtasks /end /tn "accli-mount-nfs" 2> $null | Out-Null\n'
1257
+ ' }\n'
1258
+ '} catch {}\n\n'
1259
+ 'try {\n'
1260
+ ' Get-CimInstance Win32_Process -Filter "name=\'hf-mount-nfs.exe\'" | ForEach-Object {\n'
1261
+ ' Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue | Out-Null\n'
1262
+ ' }\n'
1263
+ '} catch {}\n\n'
1264
+ '# Force-kill nfsclnt.exe so NfsClnt never hangs in STOP_PENDING, then cycle NfsRdr & NfsClnt to flush stale kernel V_NET_ROOT cache\n'
1265
+ 'try {\n'
1266
+ ' Stop-Process -Name "nfsclnt" -Force -ErrorAction SilentlyContinue | Out-Null\n'
1267
+ ' Stop-Service -Name "NfsClnt" -Force -ErrorAction SilentlyContinue | Out-Null\n'
1268
+ ' Stop-Service -Name "NfsRdr" -Force -ErrorAction SilentlyContinue | Out-Null\n'
1269
+ ' Start-Service -Name "NfsRdr" -ErrorAction SilentlyContinue | Out-Null\n'
1270
+ ' for ($i = 0; $i -lt 5; $i++) {\n'
1271
+ ' $svc = Get-Service -Name "NfsClnt" -ErrorAction SilentlyContinue\n'
1272
+ ' if ($svc -and $svc.Status -eq \'Running\') { break }\n'
1273
+ ' Start-Service -Name "NfsClnt" -ErrorAction SilentlyContinue | Out-Null\n'
1274
+ ' Start-Sleep -Milliseconds 500\n'
1275
+ ' }\n'
1276
+ '} catch {}\n',
1277
+ encoding="utf-8",
1278
+ )
1279
+ except Exception:
1280
+ pass
1234
1281
  print("[bold green][OK] Windows NFS client features, registry policies, and Task Scheduler gateway are already configured.[/bold green]")
1235
1282
  return
1236
1283
 
@@ -1560,6 +1607,8 @@ def mount_start(
1560
1607
  print(f"[bold red][ERROR] NFS daemon started, but failed to map drive {mount_point_abs} in user session.[/bold red]")
1561
1608
  if err_msg:
1562
1609
  print(f"[red]{err_msg}[/red]")
1610
+ # Clean up the spawned daemon so a failed mount does not leave a zombie daemon running
1611
+ subprocess.run(["schtasks", "/run", "/tn", "accli-umount-nfs"], capture_output=True)
1563
1612
  print("[yellow]Tip: Make sure Windows NFS client feature was fully enabled and the PC was restarted.[/yellow]")
1564
1613
  raise typer.Exit(1)
1565
1614
  else:
@@ -1846,6 +1895,14 @@ def mount_stop(
1846
1895
  break
1847
1896
  time.sleep(0.5)
1848
1897
 
1898
+ # Wait for accli-umount-nfs to finish restarting NfsRdr/NfsClnt
1899
+ for _ in range(16):
1900
+ umount_check = subprocess.run(["schtasks", "/query", "/tn", "accli-umount-nfs"], capture_output=True, text=True, errors="replace")
1901
+ clnt_check = subprocess.run(["sc.exe", "query", "NfsClnt"], capture_output=True, text=True, errors="replace")
1902
+ if (not umount_check.stdout or "Running" not in umount_check.stdout) and (clnt_check.stdout and "RUNNING" in clnt_check.stdout):
1903
+ break
1904
+ time.sleep(0.5)
1905
+
1849
1906
  # Wait until drive letter is released from Windows namespace
1850
1907
  for _ in range(10):
1851
1908
  if not is_windows_drive_mapped(target_str):
@@ -126,12 +126,12 @@ class AccliGuiApp(tk.Tk):
126
126
  if update_avail:
127
127
  instruction = get_upgrade_instruction()
128
128
  def show_notice():
129
- self.status_bar_val.set(f"Update available: {latest} (current: {VERSION})")
130
- self.append_log(f"\n🔔 [NOTICE] A new version of accli ({latest}) is available! Current version: {VERSION}\n{instruction}\n\n")
129
+ self.status_bar_val.set(f"Update available: accli {latest} (current: {VERSION})")
130
+ self.append_log(f"\n🔔 Update available: accli {latest} (current: {VERSION})\n{instruction}\n\n")
131
131
  # Also show subtle info notification
132
132
  messagebox.showinfo(
133
133
  "Update Available",
134
- f"A new version of accli is available: {latest}\n(Currently installed: {VERSION})\n\n{instruction}"
134
+ f"Update available: accli {latest} (current: {VERSION})\n\n{instruction}"
135
135
  )
136
136
  self.after(0, show_notice)
137
137
  threading.Thread(target=worker, daemon=True).start()
@@ -152,8 +152,11 @@ if ($cfg.skip_auto_mount) {
152
152
  $env:HF_MOUNT_SKIP_AUTO_MOUNT = "1"
153
153
  }
154
154
 
155
- # Ensure NfsClnt service is started before attempting mount
155
+ # Ensure NfsRdr and NfsClnt services are started before attempting mount
156
156
  try {
157
+ if ((Get-Service -Name "NfsRdr" -ErrorAction SilentlyContinue).Status -ne 'Running') {
158
+ Start-Service -Name "NfsRdr" -ErrorAction SilentlyContinue
159
+ }
157
160
  if ((Get-Service -Name "NfsClnt" -ErrorAction SilentlyContinue).Status -ne 'Running') {
158
161
  Start-Service -Name "NfsClnt" -ErrorAction SilentlyContinue
159
162
  }
@@ -218,6 +221,20 @@ try {
218
221
  Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue | Out-Null
219
222
  }
220
223
  } catch {}
224
+
225
+ # Force-kill nfsclnt.exe so NfsClnt never hangs in STOP_PENDING, then cycle NfsRdr & NfsClnt to flush stale kernel V_NET_ROOT cache
226
+ try {
227
+ Stop-Process -Name "nfsclnt" -Force -ErrorAction SilentlyContinue | Out-Null
228
+ Stop-Service -Name "NfsClnt" -Force -ErrorAction SilentlyContinue | Out-Null
229
+ Stop-Service -Name "NfsRdr" -Force -ErrorAction SilentlyContinue | Out-Null
230
+ Start-Service -Name "NfsRdr" -ErrorAction SilentlyContinue | Out-Null
231
+ for ($i = 0; $i -lt 5; $i++) {
232
+ $svc = Get-Service -Name "NfsClnt" -ErrorAction SilentlyContinue
233
+ if ($svc -and $svc.Status -eq 'Running') { break }
234
+ Start-Service -Name "NfsClnt" -ErrorAction SilentlyContinue | Out-Null
235
+ Start-Sleep -Milliseconds 500
236
+ }
237
+ } catch {}
221
238
  '@
222
239
 
223
240
  $helperUmountScriptPath = "C:\ProgramData\accli\run-umount-helper.ps1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accli
3
- Version: 2.1.1
3
+ Version: 2.1.3
4
4
  Summary: IIASA Accelerator Client
5
5
  Author-email: Wrufesh S <wrufesh@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -70,7 +70,7 @@ This client uses **device authentication** via Auth0.
70
70
 
71
71
  ### ✅ Requirements
72
72
 
73
- - Python >= 3.7.17
73
+ - Python >= 3.8
74
74
 
75
75
  ### 📦 Installation
76
76
 
@@ -29,4 +29,5 @@ accli.egg-info/top_level.txt
29
29
  tests/test_jobs_commands.py
30
30
  tests/test_log_timeline.py
31
31
  tests/test_logs_command.py
32
- tests/test_mount_lifecycle.py
32
+ tests/test_mount_lifecycle.py
33
+ tests/test_update_check.py
@@ -0,0 +1,151 @@
1
+ """Verify that `check_for_updates` runs via the root callback for all CLI commands with a unified design."""
2
+ import unittest
3
+ from unittest.mock import patch
4
+
5
+ from typer.testing import CliRunner
6
+
7
+ from accli import cli
8
+ from accli._version import VERSION
9
+
10
+
11
+ class _FakeService:
12
+ def get_job_logs(self, *args, **kwargs):
13
+ return dict(chunks=[], events=[], after=None, before=None, has_more_before=False, job_completed=True)
14
+
15
+ def list_root_jobs(self, *args, **kwargs):
16
+ return dict(results=[], count=0)
17
+
18
+ def get_job_graph(self, *args, **kwargs):
19
+ return dict(
20
+ root_job_id=1,
21
+ graph_status="DONE",
22
+ jobs=[
23
+ dict(
24
+ id=1,
25
+ name="root",
26
+ job_executor_id="WKUBE",
27
+ job_entry_location="main.py",
28
+ status="DONE",
29
+ parent_job_id=None,
30
+ predecessor_job_id=None,
31
+ status_at=None,
32
+ created_at=None,
33
+ )
34
+ ],
35
+ )
36
+
37
+
38
+ ALL_COMMAND_INVOCATIONS = [
39
+ [],
40
+ ["-h"],
41
+ ["--help"],
42
+ ["--version"],
43
+ ["-v"],
44
+ ["about"],
45
+ ["gui"],
46
+ ["login"],
47
+ ["validate", "demo", "tmpl", "file.csv"],
48
+ ["dispatch", "demo", "root_task", "-f", "nonexistent_wkube.py"],
49
+ ["logs", "demo", "1"],
50
+ ["jobs", "demo"],
51
+ ["job", "demo", "1"],
52
+ ["copy", "local_a", "local_b"],
53
+ ["mount", "start", "demo", "--mode", "invalid"],
54
+ ["mount", "stop", "invalid_drive"],
55
+ ["mount", "status"],
56
+ ]
57
+
58
+
59
+ class TestUpdateCheckAllCommands(unittest.TestCase):
60
+ def setUp(self):
61
+ import accli.gui
62
+
63
+ class _FakeResp:
64
+ status_code = 200
65
+
66
+ @staticmethod
67
+ def json():
68
+ return {"access_token": "tok", "refresh_token": "ref"}
69
+
70
+ self.patches = [
71
+ patch.object(accli.gui, "main", lambda: None),
72
+ patch.object(cli.typer, "prompt", lambda *a, **kw: "fake-code"),
73
+ patch.object(cli.requests, "post", lambda *a, **kw: _FakeResp()),
74
+ patch.object(cli, "save_token_details", lambda *a, **kw: None),
75
+ patch.object(cli, "AcceleratorTerminalCliProjectService", lambda **kw: _FakeService()),
76
+ patch.object(cli, "CsvRegionalTimeseriesValidator", lambda **kw: (lambda: None)),
77
+ patch.object(cli, "_cli_service_for", lambda slug: _FakeService()),
78
+ patch.object(cli, "get_token", lambda: ""),
79
+ patch.object(cli, "get_server_url", lambda: "https://acc.example"),
80
+ patch.object(cli, "set_project_slug", lambda slug: None),
81
+ patch.object(cli, "exchange_refresh_token", lambda slug: ("", "token", 0)),
82
+ patch("platform.system", lambda: "Windows"),
83
+ patch.object(cli, "is_nfs_daemon_running", lambda: False),
84
+ patch.object(cli, "stop_nfs_watcher", lambda *a, **kw: None),
85
+ patch.object(cli, "is_windows_drive_mapped", lambda *a, **kw: False),
86
+ patch.object(cli, "cleanup_stuck_windows_mount_processes", lambda: None),
87
+ ]
88
+ for p in self.patches:
89
+ p.start()
90
+
91
+ def tearDown(self):
92
+ for p in reversed(self.patches):
93
+ p.stop()
94
+
95
+ def test_all_registered_commands_are_covered(self):
96
+ """Ensure every command registered on `app` and `mount_app` is included in ALL_COMMAND_INVOCATIONS."""
97
+ root_commands = {cmd.name or cmd.callback.__name__ for cmd in cli.app.registered_commands}
98
+ mount_commands = {cmd.name or cmd.callback.__name__ for cmd in cli.mount_app.registered_commands}
99
+
100
+ tested_root = {args[0] for args in ALL_COMMAND_INVOCATIONS if args and not args[0].startswith("-")}
101
+ tested_mount = {args[1] for args in ALL_COMMAND_INVOCATIONS if args[:1] == ["mount"] and len(args) > 1}
102
+
103
+ self.assertTrue(root_commands <= tested_root, f"Missing root commands: {root_commands - tested_root}")
104
+ self.assertTrue(mount_commands <= tested_mount, f"Missing mount commands: {mount_commands - tested_mount}")
105
+
106
+ def test_update_notice_shown_once_on_every_command(self):
107
+ runner = CliRunner()
108
+ expected_banner = f"🔔 Update available: accli 99.0.0 (current: {VERSION})"
109
+ expected_instruction = "To update, run: pip install -U accli"
110
+
111
+ for args in ALL_COMMAND_INVOCATIONS:
112
+ with self.subTest(command=" ".join(args)):
113
+ calls = []
114
+
115
+ def fake_check():
116
+ calls.append(1)
117
+ return True, "99.0.0"
118
+
119
+ with patch.object(cli, "check_for_updates", fake_check), patch.object(
120
+ cli, "get_upgrade_instruction", lambda: expected_instruction
121
+ ):
122
+ result = runner.invoke(cli.app, args, env={"COLUMNS": "200"})
123
+
124
+ self.assertEqual(
125
+ len(calls),
126
+ 1,
127
+ f"Expected check_for_updates to be called once for {args}, got {len(calls)}",
128
+ )
129
+ self.assertEqual(result.output.count(expected_banner), 1, result.output)
130
+ self.assertEqual(result.output.count(expected_instruction), 1, result.output)
131
+
132
+ def test_no_update_notice_when_up_to_date_on_every_command(self):
133
+ runner = CliRunner()
134
+
135
+ for args in ALL_COMMAND_INVOCATIONS:
136
+ with self.subTest(command=" ".join(args)):
137
+ calls = []
138
+
139
+ def fake_check():
140
+ calls.append(1)
141
+ return False, None
142
+
143
+ with patch.object(cli, "check_for_updates", fake_check):
144
+ result = runner.invoke(cli.app, args, env={"COLUMNS": "200"})
145
+
146
+ self.assertEqual(len(calls), 1, f"Expected check_for_updates to be called once for {args}")
147
+ self.assertNotIn("Update available:", result.output)
148
+
149
+
150
+ if __name__ == "__main__":
151
+ unittest.main()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes