<!-- CURSOR_SUMMARY --> > [!NOTE] > **Low Risk** > Mostly CI/test and CLI output tweaks, plus a small refactor to reuse existing subprocess termination logic; low risk with minor potential for CI environment/version compatibility issues. > > **Overview** > Expands CI coverage by adding Python `3.13` and `3.14` to the GitHub Actions matrices (main tests, install test, and no-auth CLI integration), and removes a redundant editable install step in the no-auth workflow. > > Cleans up Windows subprocess handling by dropping `arcade_cli.deploy._graceful_terminate` and calling the shared `arcade_core.subprocess_utils.graceful_terminate_process` directly, with corresponding test updates. > > Improves `arcade new` scaffolding guidance by printing numbered “Next steps” with explicit stdio/HTTP run options, and adds/updates CLI tests to assert this output. Also bumps package version to `1.11.2` and tightens pre-commit `ruff` excludes (no longer excluding `_scratch`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 55c2ae106f13e5657acdbebf63e00d74c171181f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
104 lines
3.8 KiB
Python
104 lines
3.8 KiB
Python
from io import StringIO
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from arcade_cli.new import create_new_toolkit, create_new_toolkit_minimal
|
|
from rich.console import Console
|
|
|
|
|
|
def test_create_new_toolkit_prints_next_steps(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""create_new_toolkit (full template) should print numbered next steps."""
|
|
output_dir = tmp_path / "full_test"
|
|
output_dir.mkdir()
|
|
|
|
# Use a cwd that does not trigger community/official toolkit prompts
|
|
fake_cwd = tmp_path / "cwd"
|
|
fake_cwd.mkdir()
|
|
monkeypatch.chdir(fake_cwd)
|
|
|
|
# Mock prompts: description, author, email, evals (yes)
|
|
with patch("arcade_cli.new.typer.prompt", side_effect=["", "", "", "y"]):
|
|
buf = StringIO()
|
|
test_console = Console(file=buf, force_terminal=False)
|
|
import arcade_cli.new as new_mod
|
|
|
|
orig = new_mod.console
|
|
new_mod.console = test_console
|
|
try:
|
|
create_new_toolkit(str(output_dir), "my_server")
|
|
finally:
|
|
new_mod.console = orig
|
|
|
|
output = buf.getvalue()
|
|
assert "Next steps:" in output
|
|
assert "1. cd " in output
|
|
assert "2. Run the server (choose one transport):" in output
|
|
assert "- stdio: uv run server.py" in output
|
|
assert "- http: uv run server.py --transport http --port 8000" in output
|
|
assert "uv run server.py" in output
|
|
assert "my_server" in output
|
|
|
|
|
|
def test_create_new_toolkit_minimal_with_spaces(tmp_path: Path) -> None:
|
|
output_dir = tmp_path / "dir with spaces"
|
|
output_dir.mkdir()
|
|
|
|
create_new_toolkit_minimal(str(output_dir), "my_server")
|
|
|
|
server_root = output_dir / "my_server"
|
|
assert (server_root / "pyproject.toml").is_file()
|
|
assert (server_root / "src" / "my_server" / "server.py").is_file()
|
|
assert (server_root / ".env.example").is_file()
|
|
|
|
|
|
def test_create_new_toolkit_minimal_prints_next_steps(tmp_path: Path) -> None:
|
|
"""After scaffolding, the CLI should print 'Next steps' guidance."""
|
|
output_dir = tmp_path / "scaffold_test"
|
|
output_dir.mkdir()
|
|
|
|
# Capture console output by replacing the module-level console.
|
|
buf = StringIO()
|
|
test_console = Console(file=buf, force_terminal=False)
|
|
|
|
import arcade_cli.new as new_mod
|
|
|
|
orig = new_mod.console
|
|
new_mod.console = test_console
|
|
try:
|
|
create_new_toolkit_minimal(str(output_dir), "demo_srv")
|
|
finally:
|
|
new_mod.console = orig
|
|
|
|
output = buf.getvalue()
|
|
assert "Next steps:" in output, f"Expected 'Next steps:' in output:\n{output}"
|
|
assert "1. cd " in output, f"Expected numbered step 1 in output:\n{output}"
|
|
assert "2. Run the server (choose one transport):" in output, (
|
|
f"Expected numbered step 2 in output:\n{output}"
|
|
)
|
|
assert "- stdio: uv run server.py" in output, f"Expected stdio option in output:\n{output}"
|
|
assert "- http: uv run server.py --transport http --port 8000" in output, (
|
|
f"Expected HTTP option in output:\n{output}"
|
|
)
|
|
assert "uv run server.py" in output, f"Expected 'uv run server.py' in output:\n{output}"
|
|
assert "demo_srv" in output, f"Expected toolkit name in output:\n{output}"
|
|
|
|
|
|
def test_create_new_toolkit_minimal_rejects_duplicate(tmp_path: Path) -> None:
|
|
"""Creating a toolkit with a name that already exists should raise."""
|
|
output_dir = tmp_path / "dup_test"
|
|
output_dir.mkdir()
|
|
|
|
create_new_toolkit_minimal(str(output_dir), "my_srv")
|
|
|
|
with pytest.raises(FileExistsError, match="already exists"):
|
|
create_new_toolkit_minimal(str(output_dir), "my_srv")
|
|
|
|
|
|
def test_create_new_toolkit_minimal_rejects_invalid_name(tmp_path: Path) -> None:
|
|
"""Toolkit names with invalid characters should raise ValueError."""
|
|
output_dir = tmp_path / "invalid_test"
|
|
output_dir.mkdir()
|
|
|
|
with pytest.raises(ValueError, match="illegal characters"):
|
|
create_new_toolkit_minimal(str(output_dir), "My-Server!")
|