Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(api): enable strict typing for data migration wizard tests (#43872)
Eddy ZHANG002fcfeb6108
diff --git a/api/tests/unit_tests/commands/test_data_migration_wizard.py b/api/tests/unit_tests/commands/test_data_migration_wizard.pyindex 37b72060f42..8a342072db2 100644--- a/api/tests/unit_tests/commands/test_data_migration_wizard.py+++ b/api/tests/unit_tests/commands/test_data_migration_wizard.py@@ -19,20 +19,20 @@ from commands.data_migration import (from models.tools import MCPToolProvider-def test_parse_index_selection_supports_all():+def test_parse_index_selection_supports_all() -> None:assert parse_index_selection("all", ["a", "b", "c"]) == ["a", "b", "c"]-def test_wizard_command_uses_app_migration_name():+def test_wizard_command_uses_app_migration_name() -> None:assert migration_data_wizard.name == "app-migration-wizard"-def test_parse_index_selection_supports_comma_indexes():+def test_parse_index_selection_supports_comma_indexes() -> None:assert parse_index_selection("1, 3", ["a", "b", "c"]) == ["a", "c"]-def test_print_wizard_step_adds_separator(monkeypatch: pytest.MonkeyPatch):- output_lines = []+def test_print_wizard_step_adds_separator(monkeypatch: pytest.MonkeyPatch) -> None:+ output_lines: list[str] = []monkeypatch.setattr("commands.data_migration.click.echo", output_lines.append)@@ -41,21 +41,21 @@ def test_print_wizard_step_adds_separator(monkeypatch: pytest.MonkeyPatch):assert output_lines == ["", "==== App Selection ===="]-def test_conflict_strategy_choices_exclude_replace():+def test_conflict_strategy_choices_exclude_replace() -> None:assert CONFLICT_STRATEGY_CHOICES == ["fail", "skip", "update"]-def test_prompt_app_ids_explains_comma_selection_and_default(monkeypatch: pytest.MonkeyPatch):+def test_prompt_app_ids_explains_comma_selection_and_default(monkeypatch: pytest.MonkeyPatch) -> None:from commands.data_migration import _prompt_app_idsprompts = []- output_lines = []+ output_lines: list[str] = []apps = [type("App", (), {"id": "app-1", "name": "embedded", "mode": "workflow"})(),type("App", (), {"id": "app-2", "name": "main", "mode": "advanced-chat"})(),]- def capture_prompt(text, **kwargs):+ def capture_prompt(text: str, **kwargs: object) -> str:prompts.append((text, kwargs))return "1,2"@@ -67,8 +67,8 @@ def test_prompt_app_ids_explains_comma_selection_and_default(monkeypatch: pytestassert "Currently supported app types: workflow and chatflow." in output_lines-def test_prompt_tool_category_marks_auto_discovered_tools(monkeypatch: pytest.MonkeyPatch):- output_lines = []+def test_prompt_tool_category_marks_auto_discovered_tools(monkeypatch: pytest.MonkeyPatch) -> None:+ output_lines: list[str] = []monkeypatch.setattr("commands.data_migration.click.echo", output_lines.append)monkeypatch.setattr("commands.data_migration.click.prompt", lambda *args, **kwargs: "")@@ -85,10 +85,10 @@ def test_prompt_tool_category_marks_auto_discovered_tools(monkeypatch: pytest.Moassert output_lines[:2] == ["", "==== Custom API tools ===="]-def test_prompt_tool_category_explains_comma_selection_and_default(monkeypatch: pytest.MonkeyPatch):+def test_prompt_tool_category_explains_comma_selection_and_default(monkeypatch: pytest.MonkeyPatch) -> None:prompts = []- def capture_prompt(text, **kwargs):+ def capture_prompt(text: str, **kwargs: object) -> str:prompts.append((text, kwargs))return ""@@ -110,10 +110,10 @@ def test_prompt_tool_category_explains_comma_selection_and_default(monkeypatch:]-def test_prompt_output_file_shows_default(monkeypatch: pytest.MonkeyPatch):+def test_prompt_output_file_shows_default(monkeypatch: pytest.MonkeyPatch) -> None:prompts = []- def capture_prompt(text, **kwargs):+ def capture_prompt(text: str, **kwargs: object) -> str:prompts.append((text, kwargs))return "migration-data.json"@@ -124,7 +124,7 @@ def test_prompt_output_file_shows_default(monkeypatch: pytest.MonkeyPatch):assert prompts[0][1]["show_default"] is True-def test_prompt_tool_category_marks_auto_by_detail_and_supports_multi_select(monkeypatch: pytest.MonkeyPatch):+def test_prompt_tool_category_marks_auto_by_detail_and_supports_multi_select(monkeypatch: pytest.MonkeyPatch) -> None:monkeypatch.setattr("commands.data_migration.click.echo", lambda *_args, **_kwargs: None)monkeypatch.setattr("commands.data_migration.click.prompt", lambda *args, **kwargs: "1,2")@@ -137,14 +137,14 @@ def test_prompt_tool_category_marks_auto_by_detail_and_supports_multi_select(monassert selected == ["tool-1", "tool-2"]-def test_prompt_tool_category_marks_auto_by_value():- output_lines = []+def test_prompt_tool_category_marks_auto_by_value() -> None:+ output_lines: list[str] = []from commands import data_migrationoriginal_echo = data_migration.click.echooriginal_prompt = data_migration.click.prompt- data_migration.click.echo = output_lines.append+ data_migration.click.echo = output_lines.append # pyrefly: ignore[bad-assignment]data_migration.click.prompt = lambda *args, **kwargs: ""try:_prompt_tool_category(@@ -159,8 +159,8 @@ def test_prompt_tool_category_marks_auto_by_value():assert "1. [auto] embedded_workflow_as_tool (tool-1)" in output_lines-def test_print_auto_tools_lists_each_category(monkeypatch: pytest.MonkeyPatch):- output_lines = []+def test_print_auto_tools_lists_each_category(monkeypatch: pytest.MonkeyPatch) -> None:+ output_lines: list[str] = []monkeypatch.setattr("commands.data_migration.click.echo", output_lines.append)@@ -208,11 +208,11 @@ def test_resolve_mcp_tool_names_does_not_compare_non_uuid_identifier_to_uuid_id(assert resolved == {provider.name: provider.id}-def test_prompt_additional_tools_prints_final_selection_when_skipped(monkeypatch: pytest.MonkeyPatch):- output_lines = []- confirm_prompts = []+def test_prompt_additional_tools_prints_final_selection_when_skipped(monkeypatch: pytest.MonkeyPatch) -> None:+ output_lines: list[str] = []+ confirm_prompts: list[tuple[str, dict[str, object]]] = []- def capture_confirm(prompt, **kwargs):+ def capture_confirm(prompt: str, **kwargs: object) -> bool:confirm_prompts.append((prompt, kwargs))return False@@ -236,8 +236,8 @@ def test_prompt_additional_tools_prints_final_selection_when_skipped(monkeypatchassert "- [auto] weather: 3bac3aa9-dd87-4351-9459-a7099137b028" in output_lines-def test_final_tool_selection_deduplicates_manual_tool_already_auto(monkeypatch: pytest.MonkeyPatch):- output_lines = []+def test_final_tool_selection_deduplicates_manual_tool_already_auto(monkeypatch: pytest.MonkeyPatch) -> None:+ output_lines: list[str] = []monkeypatch.setattr("commands.data_migration.click.echo", output_lines.append)@@ -259,7 +259,7 @@ def test_final_tool_selection_deduplicates_manual_tool_already_auto(monkeypatch:assert not any(line.startswith("- [manual]") for line in output_lines)-def test_prompt_output_file_rejects_yes_no_typo(monkeypatch: pytest.MonkeyPatch):+def test_prompt_output_file_rejects_yes_no_typo(monkeypatch: pytest.MonkeyPatch) -> None:import clickimport pytest@@ -269,9 +269,9 @@ def test_prompt_output_file_rejects_yes_no_typo(monkeypatch: pytest.MonkeyPatch)_prompt_output_file()-def test_confirm_wizard_summary_shows_conflict_strategy(monkeypatch: pytest.MonkeyPatch):- output_lines = []- confirm_prompts = []+def test_confirm_wizard_summary_shows_conflict_strategy(monkeypatch: pytest.MonkeyPatch) -> None:+ output_lines: list[str] = []+ confirm_prompts: list[tuple[str, dict[str, object]]] = []monkeypatch.setattr("commands.data_migration.click.echo", output_lines.append)monkeypatch.setattr(@@ -298,8 +298,8 @@ def test_confirm_wizard_summary_shows_conflict_strategy(monkeypatch: pytest.Monkassert confirm_prompts == [("Write migration package? [y/n, default: y]", {"default": True, "show_default": False})]-def test_confirm_wizard_summary_shows_final_deduplicated_tool_selection(monkeypatch: pytest.MonkeyPatch):- output_lines = []+def test_confirm_wizard_summary_shows_final_deduplicated_tool_selection(monkeypatch: pytest.MonkeyPatch) -> None:+ output_lines: list[str] = []monkeypatch.setattr("commands.data_migration.click.echo", output_lines.append)monkeypatch.setattr("commands.data_migration.click.confirm", lambda *args, **kwargs: True)@@ -343,18 +343,20 @@ def test_confirm_wizard_summary_shows_final_deduplicated_tool_selection(monkeypaassert "- [manual] weather-id" not in output_lines-def test_import_options_prompts_explain_secrets_reuse_and_conflicts(monkeypatch: pytest.MonkeyPatch):+def test_import_options_prompts_explain_secrets_reuse_and_conflicts(monkeypatch: pytest.MonkeyPatch) -> None:+ import click+from commands.data_migration import _prompt_import_options- output_lines = []- confirm_prompts = []+ output_lines: list[str] = []+ confirm_prompts: list[tuple[str, dict[str, object]]] = []prompt_calls = []- def capture_confirm(prompt, **kwargs):+ def capture_confirm(prompt: str, **kwargs: object) -> bool:confirm_prompts.append((prompt, kwargs))return False- def capture_prompt(prompt, **kwargs):+ def capture_prompt(prompt: str, **kwargs: object) -> object:prompt_calls.append((prompt, kwargs))return kwargs["default"]@@ -394,8 +396,12 @@ def test_import_options_prompts_explain_secrets_reuse_and_conflicts(monkeypatch:assert prompt_calls[0][0] == "Import ID strategy. Enter one of: preserve-id, generate-new-id"assert prompt_calls[0][1]["default"] == "preserve-id"assert prompt_calls[0][1]["show_default"] is True- assert list(prompt_calls[0][1]["type"].choices) == ID_STRATEGY_CHOICES+ id_strategy_type = prompt_calls[0][1]["type"]+ assert isinstance(id_strategy_type, click.Choice)+ assert list(id_strategy_type.choices) == ID_STRATEGY_CHOICESassert prompt_calls[1][0] == "Import conflict strategy. Enter one of: fail, skip, update"assert prompt_calls[1][1]["default"] == "update"assert prompt_calls[1][1]["show_default"] is True- assert list(prompt_calls[1][1]["type"].choices) == CONFLICT_STRATEGY_CHOICES+ conflict_strategy_type = prompt_calls[1][1]["type"]+ assert isinstance(conflict_strategy_type, click.Choice)+ assert list(conflict_strategy_type.choices) == CONFLICT_STRATEGY_CHOICESdiff --git a/api/tests/unit_tests/pyrefly.toml b/api/tests/unit_tests/pyrefly.tomlindex 203f960f68b..2b860d6cc4c 100644--- a/api/tests/unit_tests/pyrefly.toml+++ b/api/tests/unit_tests/pyrefly.toml@@ -17,7 +17,6 @@ project-excludes = ["commands/test_archive_workflow_runs.py","commands/test_clean_expired_messages.py","commands/test_data_migration_commands.py",- "commands/test_data_migration_wizard.py","commands/test_generate_swagger_markdown_docs.py","commands/test_generate_swagger_specs.py","commands/test_lint_response_contracts.py",