test: add tmp_path type (#40724)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Asuka Minato
2026-08-21 06:09:39 +00:00
committed by GitHub
parent 5827ce2adf
commit 6ce0976265
7 changed files with 31 additions and 27 deletions
@@ -69,7 +69,7 @@ def test_export_template_command_prints_scripted_json_template():
}
def test_export_template_command_writes_output_file(tmp_path):
def test_export_template_command_writes_output_file(tmp_path: Path):
output_file = tmp_path / "export-template.json"
result = CliRunner().invoke(export_migration_data_template, ["--output", str(output_file)])
@@ -79,7 +79,7 @@ def test_export_template_command_writes_output_file(tmp_path):
assert json.loads(output_file.read_text())["apps"]["all"] is True
def test_export_template_command_requires_overwrite_for_existing_output(tmp_path):
def test_export_template_command_requires_overwrite_for_existing_output(tmp_path: Path):
output_file = tmp_path / "export-template.json"
output_file.write_text("{}")
@@ -196,7 +196,7 @@ def test_patch_union_schema_markdown_fills_converter_blank_schema_types(tmp_path
assert "| allowed_file_types | [ [FileType](#filetype) ] | | No |" in patched
def test_patch_union_schema_markdown_fills_regular_schema_union_property(tmp_path):
def test_patch_union_schema_markdown_fills_regular_schema_union_property(tmp_path: Path):
module = _load_generate_swagger_markdown_docs_module()
spec_path = tmp_path / "service-openapi.json"
spec_path.write_text(
@@ -282,7 +282,7 @@ def test_patch_union_schema_markdown_fills_array_item_union_property(tmp_path: P
) in patched
def test_patch_union_schema_markdown_ignores_specs_without_schemas(tmp_path):
def test_patch_union_schema_markdown_ignores_specs_without_schemas(tmp_path: Path):
module = _load_generate_swagger_markdown_docs_module()
spec_path = tmp_path / "console-openapi.json"
spec_path.write_text("{}", encoding="utf-8")
@@ -60,7 +60,7 @@ def _nullable_schema_ref(schema):
return next(item["$ref"] for item in schema["anyOf"] if "$ref" in item)
def test_generate_specs_writes_console_web_and_service_openapi_files(tmp_path):
def test_generate_specs_writes_console_web_and_service_openapi_files(tmp_path: Path):
module = _load_generate_swagger_specs_module()
written_paths = module.generate_specs(tmp_path)
@@ -78,7 +78,7 @@ def test_generate_specs_writes_console_web_and_service_openapi_files(tmp_path):
assert "paths" in payload
def test_generate_specs_writes_openapi_with_resolvable_references_and_no_nulls(tmp_path):
def test_generate_specs_writes_openapi_with_resolvable_references_and_no_nulls(tmp_path: Path):
module = _load_generate_swagger_specs_module()
written_paths = module.generate_specs(tmp_path)
@@ -98,7 +98,7 @@ def test_generate_specs_writes_openapi_with_resolvable_references_and_no_nulls(t
assert all(value is not None for value in _walk_values(payload))
def test_generate_specs_writes_unique_operation_ids(tmp_path):
def test_generate_specs_writes_unique_operation_ids(tmp_path: Path):
module = _load_generate_swagger_specs_module()
written_paths = module.generate_specs(tmp_path)
@@ -110,7 +110,7 @@ def test_generate_specs_writes_unique_operation_ids(tmp_path):
assert len(operation_ids) == len(set(operation_ids))
def test_system_features_specs_exclude_backend_only_fields(tmp_path):
def test_system_features_specs_exclude_backend_only_fields(tmp_path: Path):
module = _load_generate_swagger_specs_module()
written_paths = module.generate_specs(tmp_path)
@@ -131,7 +131,7 @@ def test_system_features_specs_exclude_backend_only_fields(tmp_path):
assert "PluginManagerModel" not in schemas
def test_generate_specs_writes_get_operations_without_request_bodies(tmp_path):
def test_generate_specs_writes_get_operations_without_request_bodies(tmp_path: Path):
module = _load_generate_swagger_specs_module()
written_paths = module.generate_specs(tmp_path)
@@ -142,7 +142,7 @@ def test_generate_specs_writes_get_operations_without_request_bodies(tmp_path):
assert all("requestBody" not in operation for operation in _get_operations(payload))
def test_generate_specs_writes_service_api_reference_descriptions(tmp_path):
def test_generate_specs_writes_service_api_reference_descriptions(tmp_path: Path):
module = _load_generate_swagger_specs_module()
written_paths = module.generate_specs(tmp_path)
@@ -175,7 +175,7 @@ def test_standalone_inline_model_name_includes_list_constraints():
assert module._inline_model_name(first_inline_model) != module._inline_model_name(second_inline_model)
def test_generate_specs_is_idempotent(tmp_path):
def test_generate_specs_is_idempotent(tmp_path: Path):
module = _load_generate_swagger_specs_module()
first_paths = module.generate_specs(tmp_path / "first")
@@ -186,7 +186,7 @@ def test_generate_specs_is_idempotent(tmp_path):
assert first_path.read_text(encoding="utf-8") == second_path.read_text(encoding="utf-8")
def test_generate_specs_include_agent_v2_knowledge_set_schema_and_query_enums(tmp_path):
def test_generate_specs_include_agent_v2_knowledge_set_schema_and_query_enums(tmp_path: Path):
module = _load_generate_swagger_specs_module()
written_paths = module.generate_specs(tmp_path)
@@ -201,7 +201,7 @@ def test_generate_specs_include_agent_v2_knowledge_set_schema_and_query_enums(tm
assert schemas["AgentKnowledgeQueryMode"]["enum"] == ["generated_query", "user_query"]
def test_generate_specs_include_console_contract_shapes_for_schema_migration(tmp_path):
def test_generate_specs_include_console_contract_shapes_for_schema_migration(tmp_path: Path):
module = _load_generate_swagger_specs_module()
written_paths = module.generate_specs(tmp_path)
@@ -2,6 +2,7 @@
import json
from collections.abc import Iterator
from pathlib import Path
import pytest
from flask import Flask
@@ -617,7 +618,7 @@ def test_console_member_invite_documents_bad_request_response():
}
def test_console_plugin_category_list_exported_schema_uses_typed_items(tmp_path):
def test_console_plugin_category_list_exported_schema_uses_typed_items(tmp_path: Path):
from dev.generate_swagger_specs import generate_specs
written_paths = generate_specs(tmp_path)
@@ -658,7 +659,7 @@ def test_console_plugin_category_list_exported_schema_uses_typed_items(tmp_path)
assert field in builtin_tool_schema["properties"]
def test_console_installed_plugin_ids_exported_schema_is_lightweight(tmp_path):
def test_console_installed_plugin_ids_exported_schema_is_lightweight(tmp_path: Path):
from dev.generate_swagger_specs import generate_specs
written_paths = generate_specs(tmp_path)
@@ -691,7 +692,7 @@ def test_console_installed_plugin_ids_exported_schema_is_lightweight(tmp_path):
}
def test_console_model_provider_summary_exported_schema_is_lightweight(tmp_path):
def test_console_model_provider_summary_exported_schema_is_lightweight(tmp_path: Path):
from dev.generate_swagger_specs import generate_specs
written_paths = generate_specs(tmp_path)
@@ -3,6 +3,7 @@ from __future__ import annotations
import uuid
from contextlib import nullcontext
from datetime import datetime
from pathlib import Path
from unittest.mock import patch
import pytest
@@ -148,7 +149,7 @@ def test_is_valid_uuid_handles_valid_invalid_and_empty_values():
assert is_valid_uuid(None) is False
def test_load_yaml_file_valid(tmp_path):
def test_load_yaml_file_valid(tmp_path: Path):
valid_file = tmp_path / "valid.yaml"
valid_file.write_text("a: 1\nb: two\n", encoding="utf-8")
@@ -157,12 +158,12 @@ def test_load_yaml_file_valid(tmp_path):
assert loaded == {"a": 1, "b": "two"}
def test_load_yaml_file_missing(tmp_path):
def test_load_yaml_file_missing(tmp_path: Path):
with pytest.raises(FileNotFoundError):
_load_yaml_file(file_path=str(tmp_path / "missing.yaml"))
def test_load_yaml_file_invalid(tmp_path):
def test_load_yaml_file_invalid(tmp_path: Path):
invalid_file = tmp_path / "invalid.yaml"
invalid_file.write_text("a: [1, 2\n", encoding="utf-8")
@@ -170,7 +171,7 @@ def test_load_yaml_file_invalid(tmp_path):
_load_yaml_file(file_path=str(invalid_file))
def test_load_yaml_file_cached_hits(tmp_path):
def test_load_yaml_file_cached_hits(tmp_path: Path):
valid_file = tmp_path / "valid.yaml"
valid_file.write_text("a: 1\nb: two\n", encoding="utf-8")
@@ -1,4 +1,5 @@
import json
from pathlib import Path
import pytest
@@ -6,7 +7,7 @@ from services.data_migration.entities import MigrationDataError
from services.data_migration.package_service import MigrationPackageService
def test_load_package_rejects_branch_draft_shape(tmp_path):
def test_load_package_rejects_branch_draft_shape(tmp_path: Path):
package_file = tmp_path / "draft.json"
package_file.write_text(json.dumps({"workflows": [], "tools": []}), encoding="utf-8")
@@ -14,7 +15,7 @@ def test_load_package_rejects_branch_draft_shape(tmp_path):
MigrationPackageService().load_package(package_file)
def test_load_package_rejects_unsupported_version(tmp_path):
def test_load_package_rejects_unsupported_version(tmp_path: Path):
package_file = tmp_path / "future.json"
package_file.write_text(json.dumps({"metadata": {"version": "999", "source_scope": "single"}}), encoding="utf-8")
@@ -22,7 +23,7 @@ def test_load_package_rejects_unsupported_version(tmp_path):
MigrationPackageService().load_package(package_file)
def test_save_package_writes_versioned_shape(tmp_path):
def test_save_package_writes_versioned_shape(tmp_path: Path):
output_file = tmp_path / "migration-data.json"
package = MigrationPackageService().build_empty_package(
source_tenant_id="tenant-1",
@@ -40,7 +41,7 @@ def test_save_package_writes_versioned_shape(tmp_path):
assert data["dependencies"] == []
def test_save_package_without_overwrite_fails_when_file_exists(tmp_path):
def test_save_package_without_overwrite_fails_when_file_exists(tmp_path: Path):
output_file = tmp_path / "migration-data.json"
output_file.write_text("{}", encoding="utf-8")
package = MigrationPackageService().build_empty_package(
@@ -1,4 +1,5 @@
import json
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
@@ -120,7 +121,7 @@ class TestHandlePluginInstanceInstall:
assert result["success"] == []
assert result["failed"] == ["langgenius/openai"]
def test_install_plugins_invalidates_cache_after_direct_tenant_install(self, tmp_path) -> None:
def test_install_plugins_invalidates_cache_after_direct_tenant_install(self, tmp_path: Path) -> None:
extracted_plugins = tmp_path / "plugins.jsonl"
output_file = tmp_path / "output.json"
extracted_plugins.write_text('{"tenant_id":"tenant1","plugins":["langgenius/openai"]}\n')
@@ -146,7 +147,7 @@ class TestHandlePluginInstanceInstall:
mock_installer.install_from_identifiers.assert_called_once()
invalidate_cache.assert_called_once_with("tenant1")
def test_install_plugins_reports_missing_plugin_ids(self, tmp_path) -> None:
def test_install_plugins_reports_missing_plugin_ids(self, tmp_path: Path) -> None:
extracted_plugins = tmp_path / "plugins.jsonl"
output_file = tmp_path / "output.json"
extracted_plugins.write_text('{"tenant_id":"tenant1","plugins":["langgenius/openai","langgenius/missing"]}\n')
@@ -177,7 +178,7 @@ class TestHandlePluginInstanceInstall:
]
mock_installer.install_from_identifiers.assert_called_once()
def test_install_plugins_skips_unresolved_plugins(self, tmp_path) -> None:
def test_install_plugins_skips_unresolved_plugins(self, tmp_path: Path) -> None:
extracted_plugins = tmp_path / "plugins.jsonl"
output_file = tmp_path / "output.json"
extracted_plugins.write_text('{"tenant_id":"tenant1","plugins":["langgenius/missing"]}\n')