import io from pathlib import Path import subprocess import sys from unittest import mock import click import pytest import os from click.testing import CliRunner from crewai_core import plus_api from crewai_cli.authentication.token import AuthError from crewai_cli.cli import ( create, crewai, deploy_create, deploy_list, deploy_logs, deploy_push, deploy_remove, deply_status, evaluate_crew, flow_add_crew, flow_run, log_tasks_outputs, login, replay, reset_memories, run, test, traces_status, train, version, ) from crewai_core.user_data import update_user_data @pytest.fixture def runner(): return CliRunner() @mock.patch("crewai_cli.cli.train_crew") def test_train_default_iterations(train_crew, runner): result = runner.invoke(train) train_crew.assert_called_once_with(5, "trained_agents_data.pkl") assert result.exit_code == 0 assert "Training the Crew for 5 iterations" in result.output @mock.patch("crewai_cli.cli.train_crew") def test_train_custom_iterations(train_crew, runner): result = runner.invoke(train, ["--n-iterations", "10"]) train_crew.assert_called_once_with(10, "trained_agents_data.pkl") assert result.exit_code == 0 assert "Training the Crew for 10 iterations" in result.output @mock.patch("crewai_cli.cli.train_crew") def test_train_custom_iterations_snake_case_alias(train_crew, runner): result = runner.invoke(train, ["--n_iterations", "10"]) train_crew.assert_called_once_with(10, "trained_agents_data.pkl") assert result.exit_code == 0 assert "Training the Crew for 10 iterations" in result.output assert ( "Warning: The flag '--n_iterations' is deprecated. Use '--n-iterations' instead." in result.output ) @mock.patch("crewai_cli.cli.train_crew") def test_train_invalid_string_iterations(train_crew, runner): result = runner.invoke(train, ["--n-iterations", "invalid"]) train_crew.assert_not_called() assert result.exit_code == 2 assert ( "Usage: train [OPTIONS]\nTry 'train --help' for help.\n\nError: Invalid value for '-n' / '--n-iterations': 'invalid' is not a valid integer.\n" in result.output ) def test_reset_no_memory_flags(runner): result = runner.invoke( reset_memories, ) assert ( result.output == "Please specify at least one memory type to reset using the appropriate flags.\n" ) def test_version_flag(runner): result = runner.invoke(version) assert result.exit_code == 0 assert "crewai version:" in result.output def test_version_command(runner): result = runner.invoke(version) assert result.exit_code == 0 assert "crewai version:" in result.output def test_version_command_with_tools(runner): result = runner.invoke(version, ["--tools"]) assert result.exit_code == 0 assert "crewai version:" in result.output assert ( "crewai tools version:" in result.output or "crewai tools not installed" in result.output ) @mock.patch("crewai_cli.cli.evaluate_crew") def test_test_default_iterations(evaluate_crew, runner): result = runner.invoke(test) evaluate_crew.assert_called_once_with(3, "gpt-6-luna", trained_agents_file=None) assert result.exit_code == 0 assert "Testing the crew for 3 iterations with model gpt-6-luna" in result.output @mock.patch("crewai_cli.cli.evaluate_crew") def test_test_custom_iterations(evaluate_crew, runner): result = runner.invoke(test, ["--n-iterations", "5", "--model", "gpt-4o"]) evaluate_crew.assert_called_once_with(5, "gpt-4o", trained_agents_file=None) assert result.exit_code == 0 assert "Testing the crew for 5 iterations with model gpt-4o" in result.output @mock.patch("crewai_cli.cli.evaluate_crew") def test_test_custom_iterations_snake_case_alias(evaluate_crew, runner): result = runner.invoke(test, ["--n_iterations", "5", "--model", "gpt-4o"]) evaluate_crew.assert_called_once_with(5, "gpt-4o", trained_agents_file=None) assert result.exit_code == 0 assert "Testing the crew for 5 iterations with model gpt-4o" in result.output assert ( "Warning: The flag '--n_iterations' is deprecated. Use '--n-iterations' instead." in result.output ) @mock.patch("crewai_cli.cli.evaluate_crew") def test_test_invalid_string_iterations(evaluate_crew, runner): result = runner.invoke(test, ["--n-iterations", "invalid"]) evaluate_crew.assert_not_called() assert result.exit_code == 2 assert ( "Usage: test [OPTIONS]\nTry 'test --help' for help.\n\nError: Invalid value for '-n' / '--n-iterations': 'invalid' is not a valid integer.\n" in result.output ) def test_train_help_hides_legacy_flag_aliases(runner): result = runner.invoke(train, ["--help"]) assert result.exit_code == 0 assert "--n-iterations" in result.output assert "--n_iterations" not in result.output def test_test_help_hides_legacy_flag_aliases(runner): result = runner.invoke(test, ["--help"]) assert result.exit_code == 0 assert "--n-iterations" in result.output assert "--n_iterations" not in result.output def test_create_help_hides_legacy_flag_aliases(runner): result = runner.invoke(create, ["--help"]) assert result.exit_code == 0 assert "--skip-provider" in result.output assert "--skip_provider" not in result.output def test_replay_help_hides_legacy_flag_aliases(runner): result = runner.invoke(replay, ["--help"]) assert result.exit_code == 0 assert "--task-id" in result.output assert "--task_id" not in result.output @mock.patch("crewai_cli.create_json_crew.create_json_crew") def test_create_skip_provider_flag(create_json_crew, runner): result = runner.invoke(create, ["crew", "my-crew", "--skip-provider"]) assert result.exit_code == 0, result.output create_json_crew.assert_called_once_with("my-crew", None, True) assert "deprecated" not in result.output.lower() @mock.patch("crewai_cli.create_json_crew.create_json_crew") def test_create_skip_provider_snake_case_alias_warns(create_json_crew, runner): result = runner.invoke(create, ["crew", "my-crew", "--skip_provider"]) assert result.exit_code == 0, result.output create_json_crew.assert_called_once_with("my-crew", None, True) assert ( "Warning: The flag '--skip_provider' is deprecated. Use '--skip-provider' instead." in result.output ) @mock.patch("crewai_cli.cli.replay_task_command") def test_replay_task_id_flag(replay_task_command, runner): result = runner.invoke(replay, ["--task-id", "task_123"]) assert result.exit_code == 0, result.output replay_task_command.assert_called_once_with("task_123", trained_agents_file=None) assert "Replaying the crew from task task_123" in result.output @mock.patch("crewai_cli.cli.replay_task_command") def test_replay_task_id_snake_case_alias_warns(replay_task_command, runner): result = runner.invoke(replay, ["--task_id", "task_123"]) assert result.exit_code == 0, result.output replay_task_command.assert_called_once_with("task_123", trained_agents_file=None) assert ( "Warning: The flag '--task_id' is deprecated. Use '--task-id' instead." in result.output ) @mock.patch("crewai_cli.cli.replay_task_command") def test_replay_without_task_id(replay_task_command, runner): result = runner.invoke(replay) assert result.exit_code == 0, result.output replay_task_command.assert_called_once_with(None, trained_agents_file=None) assert "Replaying the crew from task None" in result.output @mock.patch("crewai_cli.cli.run_crew") def test_run_uses_project_runner_by_default(run_crew, runner): result = runner.invoke(run) assert result.exit_code == 0 run_crew.assert_called_once_with( trained_agents_file=None, definition=None, inputs=None, ) assert "experimental" not in result.output.lower() @mock.patch("crewai_cli.cli.run_crew") def test_run_with_definition_uses_project_runner(run_crew, runner): result = runner.invoke( run, ["--definition", "flow.yaml", "--inputs", '{"topic":"AI"}'], ) assert result.exit_code == 0 run_crew.assert_called_once_with( trained_agents_file=None, definition="flow.yaml", inputs='{"topic":"AI"}', ) @mock.patch("crewai_cli.cli.run_crew") def test_run_inputs_without_definition_calls_run_crew(run_crew, runner): # --inputs no longer requires --definition; the resolution happens in run_crew. result = runner.invoke(run, ["--inputs", '{"topic":"AI"}']) assert result.exit_code == 0 run_crew.assert_called_once_with( trained_agents_file=None, definition=None, inputs='{"topic":"AI"}' ) @mock.patch("crewai_cli.cli.run_crew") def test_run_rejects_filename_with_definition(run_crew, runner): result = runner.invoke(run, ["--definition", "flow.yaml", "--filename", "x.pkl"]) assert result.exit_code == 2 assert "Error: --filename can only be used when running crews" in result.output run_crew.assert_not_called() @mock.patch("crewai_cli.cli.run_crew") def test_run_passes_filename_to_project_runner(run_crew, runner): result = runner.invoke(run, ["--filename", "trained.pkl"]) assert result.exit_code == 0 run_crew.assert_called_once_with( trained_agents_file="trained.pkl", definition=None, inputs=None, ) @mock.patch("crewai_cli.cli.run_crew") def test_flow_kickoff_is_deprecated_and_uses_run_path(run_crew, runner): result = runner.invoke(flow_run) assert result.exit_code == 0 run_crew.assert_called_once_with( trained_agents_file=None, definition=None, inputs=None, ) assert ( "The command 'crewai flow kickoff' is deprecated. Use 'crewai run' instead." in result.output ) @mock.patch("crewai_cli.create_json_crew.create_json_crew") def test_create_crew_in_dmn_mode_skips_provider_prompts(create_json_crew, runner): result = runner.invoke(create, ["crew", "DMN Crew"], env={"CREWAI_DMN": "True"}) assert result.exit_code == 0 create_json_crew.assert_called_once_with("DMN Crew", None, True) @mock.patch("crewai_cli.create_flow.create_flow") def test_create_flow_declarative_uses_declarative_scaffold(create_flow, runner): result = runner.invoke(create, ["flow", "My Flow", "--declarative"]) assert result.exit_code == 0 create_flow.assert_called_once_with( "My Flow", declarative=True, provider=None, skip_provider=False ) @mock.patch("crewai_cli.create_flow.create_flow") def test_create_flow_passes_provider_and_skip_provider_through(create_flow, runner): result = runner.invoke( create, ["flow", "My Flow", "--provider", "anthropic", "--skip-provider"] ) assert result.exit_code == 0, result.output create_flow.assert_called_once_with( "My Flow", declarative=False, provider="anthropic", skip_provider=True ) @mock.patch("crewai_cli.create_json_crew.create_json_crew") def test_create_crew_rejects_declarative_flag(create_json_crew, runner): result = runner.invoke(create, ["crew", "My Crew", "--declarative"]) assert result.exit_code == 2 assert "--declarative can only be used with flow projects" in result.output create_json_crew.assert_not_called() def test_create_requires_type_in_dmn_mode(runner): result = runner.invoke(create, env={"CREWAI_DMN": "True"}) assert result.exit_code == 2 assert "TYPE is required when CREWAI_DMN is set" in result.output assert "crew, flow, agent, tool, skill, template" in result.output def test_create_requires_name_in_dmn_mode(runner): result = runner.invoke(create, ["flow"], env={"CREWAI_DMN": "True"}) assert result.exit_code == 2 assert "NAME is required when CREWAI_DMN is set" in result.output RUN_ARGV = [sys.executable, "-m", "crewai_cli.cli", "run"] PROJECT_CREATES = [ pytest.param( ["crew", "My Crew"], "crewai_cli.create_json_crew.create_json_crew", id="crew" ), pytest.param( ["crew", "My Crew", "--classic"], "crewai_cli.create_crew.create_crew", id="classic-crew", ), pytest.param(["flow", "My Flow"], "crewai_cli.create_flow.create_flow", id="flow"), pytest.param( ["flow", "My Flow", "--declarative"], "crewai_cli.create_flow.create_flow", id="declarative-flow", ), ] class _Terminal(io.StringIO): def isatty(self) -> bool: return True def _at_a_terminal( monkeypatch, typed: str, *, stdin: bool = True, stdout: bool = True ) -> None: """Run `crewai create` as a person who types ``typed``, with stdin and stdout terminals unless a test says otherwise. Call it in the test body: pytest gives the test a different captured stdout than its fixtures see.""" monkeypatch.delenv("CREWAI_DMN", raising=False) monkeypatch.setattr("sys.stdin", _Terminal(typed) if stdin else io.StringIO(typed)) monkeypatch.setattr(sys.stdout, "isatty", lambda: stdout) class _StartedRun: """A `crewai run` that create started. Ctrl-C interrupts create's wait for it ``interrupts`` times, then the run ends with ``returncode``.""" def __init__(self, args, kwargs, returncode: int, interrupts: int) -> None: self.args = args self.cwd = kwargs.get("cwd") self.env = kwargs.get("env") self.killed = False self._returncode = returncode self._interrupts = interrupts def wait(self) -> int: if self._interrupts: self._interrupts -= 1 raise KeyboardInterrupt return self._returncode def kill(self) -> None: self.killed = True terminate = kill def _record_runs( monkeypatch, returncode: int = 0, interrupts: int = 0 ) -> list[_StartedRun]: """Record each `crewai run` that create starts. Other commands, such as git, run for real.""" real_popen = subprocess.Popen runs: list[_StartedRun] = [] def fake_popen(args, **kwargs): if args != RUN_ARGV: return real_popen(args, **kwargs) runs.append(_StartedRun(args, kwargs, returncode, interrupts)) return runs[-1] monkeypatch.setattr(subprocess, "Popen", fake_popen) return runs def _create(args: list[str]) -> None: """Run `crewai create` outside CliRunner, which would swap in its own non-terminal stdin and stdout.""" create.main(args, prog_name="crewai create", standalone_mode=False) def _output(capsys) -> str: return click.unstyle(capsys.readouterr().out) @pytest.mark.parametrize(("args", "creator"), PROJECT_CREATES) def test_create_at_a_terminal_runs_the_new_project_when_enter_is_pressed( monkeypatch, capsys, args, creator ): monkeypatch.setattr(creator, lambda *_args, **_kwargs: Path("my_project")) runs = _record_runs(monkeypatch) _at_a_terminal(monkeypatch, "\n") with pytest.raises(SystemExit) as exit_info: _create(args) assert exit_info.value.code == 0 assert [(run.args, run.cwd) for run in runs] == [(RUN_ARGV, Path("my_project"))] assert "Run it now? [Y/n]" in _output(capsys) @pytest.mark.parametrize("returncode", [1, 130]) def test_create_exits_with_the_exit_code_of_the_run_it_started( monkeypatch, returncode ): monkeypatch.setattr( "crewai_cli.create_json_crew.create_json_crew", lambda *_args: Path("my_crew"), ) runs = _record_runs(monkeypatch, returncode) _at_a_terminal(monkeypatch, "y\n") with pytest.raises(SystemExit) as exit_info: _create(["crew", "My Crew"]) assert exit_info.value.code == returncode assert len(runs) == 1 @pytest.mark.parametrize(("returncode", "exit_code"), [(-2, 130), (-15, 143)]) def test_create_exits_as_a_shell_would_when_a_signal_kills_the_run( monkeypatch, returncode, exit_code ): monkeypatch.setattr( "crewai_cli.create_json_crew.create_json_crew", lambda *_args: Path("my_crew"), ) _record_runs(monkeypatch, returncode) _at_a_terminal(monkeypatch, "y\n") with pytest.raises(SystemExit) as exit_info: _create(["crew", "My Crew"]) assert exit_info.value.code == exit_code def test_create_waits_for_the_run_to_handle_ctrl_c_and_exits_with_its_code( monkeypatch, ): monkeypatch.setattr( "crewai_cli.create_json_crew.create_json_crew", lambda *_args: Path("my_crew"), ) # The terminal sends Ctrl-C to create and the run alike; the run stops with 130. runs = _record_runs(monkeypatch, returncode=130, interrupts=2) _at_a_terminal(monkeypatch, "\n") with pytest.raises(SystemExit) as exit_info: _create(["crew", "My Crew"]) assert exit_info.value.code == 130 [run] = runs assert not run.killed @pytest.mark.parametrize( "ca_bundle", ["/etc/corp/ca.pem", None], ids=["shell-ca-bundle", "no-ca-bundle"] ) def test_create_runs_the_project_with_the_ca_bundle_crewai_started_with( monkeypatch, ca_bundle ): # The proxy and CA variables crewAI started with, as crewai_core pinned them. monkeypatch.setattr( plus_api, "_MACHINE_TRANSPORT_ENV", {"SSL_CERT_FILE": ca_bundle} if ca_bundle else {}, ) monkeypatch.setenv("OPENAI_API_KEY", "sk-from-the-shell") def classic_create(*_args): # As fetching the provider list does in crewai_cli.provider. monkeypatch.setenv("SSL_CERT_FILE", "/venv/certifi/cacert.pem") return Path("my_crew") monkeypatch.setattr("crewai_cli.create_crew.create_crew", classic_create) runs = _record_runs(monkeypatch) _at_a_terminal(monkeypatch, "\n") with pytest.raises(SystemExit): _create(["crew", "My Crew", "--classic"]) [run] = runs assert run.env.get("SSL_CERT_FILE") == ca_bundle assert run.env["OPENAI_API_KEY"] == "sk-from-the-shell" @pytest.mark.parametrize(("args", "creator"), PROJECT_CREATES) def test_create_at_a_terminal_prints_how_to_run_later_when_declined( monkeypatch, capsys, args, creator ): monkeypatch.setattr(creator, lambda *_args, **_kwargs: Path("my_project")) runs = _record_runs(monkeypatch) _at_a_terminal(monkeypatch, "n\n") _create(args) assert runs == [] assert "Run it later: cd my_project && crewai run\n" in _output(capsys) @pytest.mark.parametrize( ("stdin", "stdout"), [(False, True), (True, False), (False, False)], ids=["piped-stdin", "piped-stdout", "no-terminal"], ) def test_create_without_a_terminal_does_not_offer_a_run( monkeypatch, capsys, stdin, stdout ): monkeypatch.setattr( "crewai_cli.create_flow.create_flow", lambda *_args, **_kwargs: Path("my_flow"), ) runs = _record_runs(monkeypatch) _at_a_terminal(monkeypatch, "y\n", stdin=stdin, stdout=stdout) _create(["flow", "My Flow"]) assert runs == [] assert "Run it" not in _output(capsys) @pytest.mark.parametrize(("args", "creator"), PROJECT_CREATES) def test_create_in_dmn_mode_does_not_offer_a_run_at_a_terminal( monkeypatch, capsys, args, creator ): monkeypatch.setattr(creator, lambda *_args, **_kwargs: Path("my_project")) runs = _record_runs(monkeypatch) _at_a_terminal(monkeypatch, "y\n") monkeypatch.setenv("CREWAI_DMN", "true") _create(args) assert runs == [] assert "Run it" not in _output(capsys) @pytest.mark.parametrize(("args", "creator"), PROJECT_CREATES) def test_create_does_not_offer_a_run_when_nothing_runnable_was_created( monkeypatch, capsys, args, creator ): monkeypatch.setattr(creator, lambda *_args, **_kwargs: None) runs = _record_runs(monkeypatch) _at_a_terminal(monkeypatch, "y\n") _create(args) assert runs == [] assert "Run it" not in _output(capsys) @pytest.mark.parametrize( ("args", "command"), [ (["tool", "my_tool"], "crewai_cli.tools.main.ToolCommand"), (["skill", "my-skill"], "crewai_cli.skills.main.SkillCommand"), (["template", "my-template"], "crewai_cli.cli.TemplateCommand"), ], ids=["tool", "skill", "template"], ) def test_create_tool_skill_or_template_does_not_offer_a_run( monkeypatch, capsys, args, command ): monkeypatch.setattr(command, mock.MagicMock()) runs = _record_runs(monkeypatch) _at_a_terminal(monkeypatch, "y\n") _create(args) assert runs == [] assert "Run it" not in _output(capsys) def test_create_runs_the_flow_it_just_created_from_its_folder( tmp_path, monkeypatch ): monkeypatch.chdir(tmp_path) runs = _record_runs(monkeypatch) _at_a_terminal(monkeypatch, "y\n") with pytest.raises(SystemExit): _create(["flow", "News v2.0", "--declarative"]) [run_started] = runs # A flow folder keeps the ".", which a crew folder would drop. assert run_started.cwd == Path("news_v2.0") assert (tmp_path / "news_v2.0" / "pyproject.toml").is_file() @mock.patch("crewai_cli.cli.AuthenticationCommand") def test_login(command, runner): mock_auth = command.return_value result = runner.invoke(login) assert result.exit_code == 0 mock_auth.login.assert_called_once() @mock.patch("crewai_core.auth.oauth2.webbrowser.open") @mock.patch("crewai_core.auth.oauth2.httpx.post") def test_login_exits_non_zero_when_the_login_times_out(mock_post, _open, runner): mock_post.return_value.json.return_value = { "device_code": "test_device_code", "user_code": "ABCD-EFGH", "verification_uri": "https://example.com/activate", "interval": 5, "expires_in": 0, } result = runner.invoke(login) assert result.exit_code == 1 assert "the login code expired before sign-in finished" in result.output mock_post.assert_called_once() @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_create(command, runner): mock_deploy = command.return_value result = runner.invoke(deploy_create) assert result.exit_code == 0 mock_deploy.create_crew.assert_called_once() @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_create_without_zip_keeps_the_default_source(command, runner): result = runner.invoke(deploy_create, ["-y"]) assert result.exit_code == 0 command.return_value.create_crew.assert_called_once_with( True, skip_validate=False, force_zip=False ) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_create_zip_forces_a_zip_upload(command, runner): result = runner.invoke(deploy_create, ["--zip", "-y", "--skip-validate"]) assert result.exit_code == 0 command.return_value.create_crew.assert_called_once_with( True, skip_validate=True, force_zip=True ) def test_deploy_create_help_lists_zip(runner): result = runner.invoke(deploy_create, ["--help"]) assert result.exit_code == 0 help_text = " ".join(result.output.split()) assert ( "--zip Upload the project as a ZIP even when it has a git origin remote." in help_text ) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_list(command, runner): mock_deploy = command.return_value result = runner.invoke(deploy_list) assert result.exit_code == 0 mock_deploy.list_crews.assert_called_once() @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_push(command, runner): mock_deploy = command.return_value uuid = "test-uuid" result = runner.invoke(deploy_push, ["-u", uuid]) assert result.exit_code == 0 mock_deploy.deploy.assert_called_once_with(uuid=uuid, skip_validate=False, force=False) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_push_force_goes_ahead_whatever_runs(command, runner): mock_deploy = command.return_value result = runner.invoke(deploy_push, ["-u", "test-uuid", "--force"]) assert result.exit_code == 0 mock_deploy.deploy.assert_called_once_with(uuid="test-uuid", skip_validate=False, force=True) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_push_no_uuid(command, runner): mock_deploy = command.return_value result = runner.invoke(deploy_push) assert result.exit_code == 0 mock_deploy.deploy.assert_called_once_with(uuid=None, skip_validate=False, force=False) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_status(command, runner): mock_deploy = command.return_value uuid = "test-uuid" result = runner.invoke(deply_status, ["-u", uuid]) assert result.exit_code == 0 mock_deploy.get_crew_status.assert_called_once_with(uuid=uuid) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_status_no_uuid(command, runner): mock_deploy = command.return_value result = runner.invoke(deply_status) assert result.exit_code == 0 mock_deploy.get_crew_status.assert_called_once_with(uuid=None) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_logs(command, runner): mock_deploy = command.return_value uuid = "test-uuid" result = runner.invoke(deploy_logs, ["-u", uuid]) assert result.exit_code == 0 mock_deploy.get_crew_logs.assert_called_once_with(uuid=uuid) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_logs_no_uuid(command, runner): mock_deploy = command.return_value result = runner.invoke(deploy_logs) assert result.exit_code == 0 mock_deploy.get_crew_logs.assert_called_once_with(uuid=None) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_remove(command, runner): mock_deploy = command.return_value uuid = "test-uuid" result = runner.invoke(deploy_remove, ["-u", uuid]) assert result.exit_code == 0 mock_deploy.remove_crew.assert_called_once_with(uuid=uuid) @mock.patch("crewai_cli.cli.DeployCommand") def test_deploy_remove_no_uuid(command, runner): mock_deploy = command.return_value result = runner.invoke(deploy_remove) assert result.exit_code == 0 mock_deploy.remove_crew.assert_called_once_with(uuid=None) def _flow_project( root: Path, project_name: str | None, package_dirs: list[str] ) -> Path: """Lay out a flow project at ``root`` with ``src/