mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Validate app name in adk create command
The `adk create` command now checks if the provided agent name is a valid Python identifier. An invalid name, such as one containing hyphens, will raise a `click.BadParameter` error before any files are created. Close #3977 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 853001295
This commit is contained in:
committed by
Copybara-Service
parent
9403a44f34
commit
742c9265a2
@@ -156,6 +156,23 @@ def test_run_cmd_overwrite_reject(
|
||||
)
|
||||
|
||||
|
||||
def test_run_cmd_invalid_app_name(
|
||||
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||
) -> None:
|
||||
"""Invalid app names should be rejected before creating any files."""
|
||||
monkeypatch.setattr(os, "getcwd", lambda: str(tmp_path))
|
||||
|
||||
with pytest.raises(click.BadParameter, match="Invalid app name"):
|
||||
cli_create.run_cmd(
|
||||
"my-agent",
|
||||
model="gemini-2.0-flash-001",
|
||||
google_api_key=None,
|
||||
google_cloud_project=None,
|
||||
google_cloud_region=None,
|
||||
type="code",
|
||||
)
|
||||
|
||||
|
||||
def test_run_cmd_with_type_config(
|
||||
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user