fix(cli): correct lint error and confirmation-denial step in project switch

- Wrap long f-string in project.py:977 to satisfy ruff E501 (88-char limit)
- Fix 'without yes' BDD step which incorrectly passed yes=True; now uses
  CliRunner with input='n\n' to properly simulate user denying the prompt
This commit is contained in:
2026-06-11 15:49:55 -04:00
committed by Forgejo
parent 2edb8c0be7
commit 2ea89440a3
2 changed files with 16 additions and 4 deletions
+12 -3
View File
@@ -673,10 +673,19 @@ def step_invoke_switch_fmt(context: Any, name: str, fmt: str) -> None:
@when('I invoke project-switch for "{name}" without yes')
def step_invoke_switch_no_confirm(context: Any, name: str) -> None:
"""Invoke switch with --yes to accept the confirmation programmatically."""
from cleveragents.cli.commands.project import switch
"""Invoke switch without --yes, denying the confirmation prompt."""
from typer.testing import CliRunner
_capture(context, switch, project=name, yes=True)
from cleveragents.cli.commands.project import app as project_app
_patch_project_mod(context)
try:
cli_runner = CliRunner()
result = cli_runner.invoke(project_app, ["switch", name], input="n\n")
context._cmd_output = result.output
context._cmd_failed = result.exit_code != 0
finally:
_unpatch_project_mod()
@when('I invoke project-switch for "{name}" with yes and short flag')
+4 -1
View File
@@ -1049,7 +1049,10 @@ def switch(
if not yes:
if current_active:
confirm_msg = f"Switch active project from '{current_active}' to '{proj.namespaced_name}'?"
confirm_msg = (
f"Switch active project from '{current_active}'"
f" to '{proj.namespaced_name}'?"
)
else:
confirm_msg = f"Set active project to '{proj.namespaced_name}'?"
confirm = typer.confirm(confirm_msg)