Skip to content

armgit / dify

Public Imported from GitHub
0

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.

refactor(api): enable strict typing for services plugin tests (#43926)

Eddy ZHANG5b87bb55dc7c
diff --git a/api/tests/unit_tests/pyrefly.toml b/api/tests/unit_tests/pyrefly.toml
index 9aad398ce5c..005955e0f3e 100644
--- a/api/tests/unit_tests/pyrefly.toml
+++ b/api/tests/unit_tests/pyrefly.toml
@@ -656,13 +656,7 @@ project-excludes = [
"services/enterprise/test_plugin_manager_service.py",
"services/enterprise/test_traceparent_propagation.py",
"services/hit_service.py",
- "services/plugin/conftest.py",
- "services/plugin/test_dependencies_analysis.py",
- "services/plugin/test_endpoint_service.py",
- "services/plugin/test_oauth_service.py",
- "services/plugin/test_plugin_migration.py",
"services/plugin/test_plugin_parameter_service.py",
- "services/plugin/test_plugin_service.py",
"services/plugin/test_plugin_service_installation.py",
"services/rag_pipeline/pipeline_template/test_built_in_retrieval.py",
"services/rag_pipeline/pipeline_template/test_pipeline_template_base.py",
diff --git a/api/tests/unit_tests/services/plugin/conftest.py b/api/tests/unit_tests/services/plugin/conftest.py
index ac0d0376898..9337a0cf887 100644
--- a/api/tests/unit_tests/services/plugin/conftest.py
+++ b/api/tests/unit_tests/services/plugin/conftest.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+from collections.abc import Iterator
from unittest.mock import MagicMock
import pytest
@@ -21,7 +22,7 @@ def make_features(
@pytest.fixture
-def mock_installer(monkeypatch: pytest.MonkeyPatch):
+def mock_installer(monkeypatch: pytest.MonkeyPatch) -> MagicMock:
"""Patch PluginInstaller at the service import site."""
mock = MagicMock()
monkeypatch.setattr("core.plugin.plugin_service.PluginInstaller", lambda: mock)
@@ -29,7 +30,7 @@ def mock_installer(monkeypatch: pytest.MonkeyPatch):
@pytest.fixture
-def mock_features():
+def mock_features() -> Iterator[MagicMock]:
"""Patch SystemFeatureService to return permissive defaults."""
from unittest.mock import patch
diff --git a/api/tests/unit_tests/services/plugin/test_dependencies_analysis.py b/api/tests/unit_tests/services/plugin/test_dependencies_analysis.py
index 5111c5959ab..670c4a97341 100644
--- a/api/tests/unit_tests/services/plugin/test_dependencies_analysis.py
+++ b/api/tests/unit_tests/services/plugin/test_dependencies_analysis.py
@@ -7,6 +7,7 @@ dependencies via marketplace.
from __future__ import annotations
+from collections.abc import Callable
from unittest.mock import MagicMock, patch
import pytest
@@ -16,38 +17,38 @@ from services.plugin.dependencies_analysis import DependenciesAnalysisService
class TestAnalyzeToolDependency:
- def test_valid_three_part_id(self):
+ def test_valid_three_part_id(self) -> None:
result = DependenciesAnalysisService.analyze_tool_dependency("langgenius/google/google")
assert result == "langgenius/google"
- def test_single_part_expands_to_langgenius(self):
+ def test_single_part_expands_to_langgenius(self) -> None:
result = DependenciesAnalysisService.analyze_tool_dependency("websearch")
assert result == "langgenius/websearch"
- def test_invalid_format_raises(self):
+ def test_invalid_format_raises(self) -> None:
with pytest.raises(ValueError):
DependenciesAnalysisService.analyze_tool_dependency("bad/format")
- def test_plugin_id_reference_is_preserved(self):
+ def test_plugin_id_reference_is_preserved(self) -> None:
assert DependenciesAnalysisService.analyze_tool_provider_reference("acme/search") == "acme/search"
class TestAnalyzeModelProviderDependency:
- def test_valid_three_part_id(self):
+ def test_valid_three_part_id(self) -> None:
result = DependenciesAnalysisService.analyze_model_provider_dependency("langgenius/openai/openai")
assert result == "langgenius/openai"
- def test_google_maps_to_gemini(self):
+ def test_google_maps_to_gemini(self) -> None:
result = DependenciesAnalysisService.analyze_model_provider_dependency("langgenius/google/google")
assert result == "langgenius/gemini"
- def test_single_part_expands(self):
+ def test_single_part_expands(self) -> None:
result = DependenciesAnalysisService.analyze_model_provider_dependency("anthropic")
assert result == "langgenius/anthropic"
class TestExtractExternalNodeDependencies:
- def test_legacy_agent_includes_strategy_and_plugin_tools(self):
+ def test_legacy_agent_includes_strategy_and_plugin_tools(self) -> None:
node_data = {
"type": "agent",
"agent_strategy_provider_name": "langgenius/agent/agent",
@@ -69,7 +70,7 @@ class TestExtractExternalNodeDependencies:
"acme/custom",
]
- def test_legacy_agent_accepts_plugin_id_strategy_and_legacy_tool_provider(self):
+ def test_legacy_agent_accepts_plugin_id_strategy_and_legacy_tool_provider(self) -> None:
node_data = {
"type": "agent",
"agent_strategy_provider_name": "acme/strategy",
@@ -90,7 +91,7 @@ class TestExtractExternalNodeDependencies:
"langgenius/search",
]
- def test_legacy_agent_skips_invalid_strategy_and_non_tool_parameters(self):
+ def test_legacy_agent_skips_invalid_strategy_and_non_tool_parameters(self) -> None:
node_data = {
"type": "agent",
"agent_strategy_provider_name": "invalid/provider/with/extra",
@@ -109,20 +110,22 @@ class TestExtractExternalNodeDependencies:
({"type": "agent", "agent_parameters": "invalid"}, []),
],
)
- def test_direct_plugin_references(self, node_data, expected):
+ def test_direct_plugin_references(self, node_data: dict[str, object], expected: list[str]) -> None:
assert DependenciesAnalysisService.extract_external_node_dependencies(node_data) == expected
class TestGetLeakedDependencies:
- def _make_dependency(self, identifier: str, dep_type=PluginDependencyType.Marketplace):
+ def _make_dependency(
+ self, identifier: str, dep_type: PluginDependencyType = PluginDependencyType.Marketplace
+ ) -> PluginDependency:
return PluginDependency(
type=dep_type,
value=PluginDependency.Marketplace(marketplace_plugin_unique_identifier=identifier),
)
@patch("services.plugin.dependencies_analysis.PluginInstaller")
- def test_returns_empty_when_all_present(self, mock_installer_cls):
- mock_installer_cls.return_value.fetch_missing_dependencies.return_value = []
+ def test_returns_empty_when_all_present(self, mock_installer_cls: MagicMock) -> None:
+ mock_installer_cls.return_value.fetch_missing_dependencies.return_value = list[object]()
deps = [self._make_dependency("org/plugin:1.0.0@hash")]
result = DependenciesAnalysisService.get_leaked_dependencies("t1", deps)
@@ -130,7 +133,7 @@ class TestGetLeakedDependencies:
assert result == []
@patch("services.plugin.dependencies_analysis.PluginInstaller")
- def test_returns_missing_with_version_extracted(self, mock_installer_cls):
+ def test_returns_missing_with_version_extracted(self, mock_installer_cls: MagicMock) -> None:
missing = MagicMock()
missing.plugin_unique_identifier = "org/plugin:1.2.3@hash"
missing.current_identifier = "org/plugin:1.0.0@oldhash"
@@ -144,7 +147,7 @@ class TestGetLeakedDependencies:
assert result[0].value.version == "1.2.3"
@patch("services.plugin.dependencies_analysis.PluginInstaller")
- def test_skips_present_dependencies(self, mock_installer_cls):
+ def test_skips_present_dependencies(self, mock_installer_cls: MagicMock) -> None:
missing = MagicMock()
missing.plugin_unique_identifier = "org/missing:1.0.0@hash"
missing.current_identifier = None
@@ -161,7 +164,9 @@ class TestGetLeakedDependencies:
class TestGenerateDependencies:
- def _make_installation(self, source, identifier, meta=None):
+ def _make_installation(
+ self, source: PluginInstallationSource, identifier: str, meta: dict[str, object] | None = None
+ ) -> MagicMock:
install = MagicMock()
install.source = source
install.plugin_unique_identifier = identifier
@@ -169,7 +174,7 @@ class TestGenerateDependencies:
return install
@patch("services.plugin.dependencies_analysis.PluginInstaller")
- def test_github_source(self, mock_installer_cls):
+ def test_github_source(self, mock_installer_cls: MagicMock) -> None:
install = self._make_installation(
PluginInstallationSource.Github,
"org/plugin:1.0.0@hash",
@@ -181,10 +186,11 @@ class TestGenerateDependencies:
assert len(result) == 1
assert result[0].type == PluginDependencyType.Github
+ assert isinstance(result[0].value, PluginDependency.Github)
assert result[0].value.repo == "org/repo"
@patch("services.plugin.dependencies_analysis.PluginInstaller")
- def test_marketplace_source(self, mock_installer_cls):
+ def test_marketplace_source(self, mock_installer_cls: MagicMock) -> None:
install = self._make_installation(PluginInstallationSource.Marketplace, "org/plugin:1.0.0@hash")
mock_installer_cls.return_value.fetch_plugin_installation_by_ids.return_value = [install]
@@ -193,7 +199,7 @@ class TestGenerateDependencies:
assert result[0].type == PluginDependencyType.Marketplace
@patch("services.plugin.dependencies_analysis.PluginInstaller")
- def test_package_source(self, mock_installer_cls):
+ def test_package_source(self, mock_installer_cls: MagicMock) -> None:
install = self._make_installation(PluginInstallationSource.Package, "org/plugin:1.0.0@hash")
mock_installer_cls.return_value.fetch_plugin_installation_by_ids.return_value = [install]
@@ -202,7 +208,7 @@ class TestGenerateDependencies:
assert result[0].type == PluginDependencyType.Package
@patch("services.plugin.dependencies_analysis.PluginInstaller")
- def test_remote_source_raises(self, mock_installer_cls):
+ def test_remote_source_raises(self, mock_installer_cls: MagicMock) -> None:
install = self._make_installation(PluginInstallationSource.Remote, "org/plugin:1.0.0@hash")
mock_installer_cls.return_value.fetch_plugin_installation_by_ids.return_value = [install]
@@ -210,8 +216,8 @@ class TestGenerateDependencies:
DependenciesAnalysisService.generate_dependencies("t1", ["p1"])
@patch("services.plugin.dependencies_analysis.PluginInstaller")
- def test_deduplicates_input_ids(self, mock_installer_cls):
- mock_installer_cls.return_value.fetch_plugin_installation_by_ids.return_value = []
+ def test_deduplicates_input_ids(self, mock_installer_cls: MagicMock) -> None:
+ mock_installer_cls.return_value.fetch_plugin_installation_by_ids.return_value = list[object]()
DependenciesAnalysisService.generate_dependencies("t1", ["p1", "p1", "p2"])
@@ -220,7 +226,7 @@ class TestGenerateDependencies:
class TestGenerateLatestDependencies:
- def test_returns_empty_when_marketplace_disabled(self, config_overrides):
+ def test_returns_empty_when_marketplace_disabled(self, config_overrides: Callable[..., None]) -> None:
config_overrides(MARKETPLACE_ENABLED=False)
result = DependenciesAnalysisService.generate_latest_dependencies(["p1"])
@@ -228,7 +234,9 @@ class TestGenerateLatestDependencies:
assert result == []
@patch("services.plugin.dependencies_analysis.marketplace")
- def test_returns_marketplace_deps_when_enabled(self, mock_marketplace, config_overrides):
+ def test_returns_marketplace_deps_when_enabled(
+ self, mock_marketplace: MagicMock, config_overrides: Callable[..., None]
+ ) -> None:
config_overrides(MARKETPLACE_ENABLED=True)
manifest = MagicMock()
manifest.latest_package_identifier = "org/plugin:2.0.0@newhash"
diff --git a/api/tests/unit_tests/services/plugin/test_endpoint_service.py b/api/tests/unit_tests/services/plugin/test_endpoint_service.py
index ddf80c8017a..5694a1761f4 100644
--- a/api/tests/unit_tests/services/plugin/test_endpoint_service.py
+++ b/api/tests/unit_tests/services/plugin/test_endpoint_service.py
@@ -12,7 +12,7 @@ from services.plugin.endpoint_service import EndpointService
class TestEndpointServiceDelegation:
@patch("services.plugin.endpoint_service.PluginEndpointClient")
- def test_create_delegates_correctly(self, mock_client_cls):
+ def test_create_delegates_correctly(self, mock_client_cls: MagicMock) -> None:
expected = MagicMock()
mock_client_cls.return_value.create_endpoint.return_value = expected
@@ -24,7 +24,7 @@ class TestEndpointServiceDelegation:
)
@patch("services.plugin.endpoint_service.PluginEndpointClient")
- def test_list_delegates_correctly(self, mock_client_cls):
+ def test_list_delegates_correctly(self, mock_client_cls: MagicMock) -> None:
expected = MagicMock()
mock_client_cls.return_value.list_endpoints.return_value = expected
@@ -33,7 +33,7 @@ class TestEndpointServiceDelegation:
assert result is expected
@patch("services.plugin.endpoint_service.PluginEndpointClient")
- def test_enable_disable_delegates(self, mock_client_cls):
+ def test_enable_disable_delegates(self, mock_client_cls: MagicMock) -> None:
EndpointService.enable_endpoint("t1", "u1", "ep-1")
mock_client_cls.return_value.enable_endpoint.assert_called_once()
diff --git a/api/tests/unit_tests/services/plugin/test_oauth_service.py b/api/tests/unit_tests/services/plugin/test_oauth_service.py
index a6d2aafcab7..e9798c2170f 100644
--- a/api/tests/unit_tests/services/plugin/test_oauth_service.py
+++ b/api/tests/unit_tests/services/plugin/test_oauth_service.py
@@ -7,25 +7,32 @@ with one-time use semantics, and validation error paths.
from __future__ import annotations
import json
-from unittest.mock import patch
+from unittest.mock import MagicMock, patch
import pytest
from services.plugin.oauth_service import OAuthProxyService
-def _oauth_proxy_setex_calls(redis_client) -> list:
+def _redis_mock() -> MagicMock:
+ from extensions.ext_redis import redis_client
+
+ assert isinstance(redis_client, MagicMock)
+ return redis_client
+
+
+def _oauth_proxy_setex_calls(redis_client: MagicMock) -> list[tuple[tuple[str, int, str], dict[str, object]]]:
return [call for call in redis_client.setex.call_args_list if call.args[0].startswith("oauth_proxy_context:")]
class TestCreateProxyContext:
- def test_stores_context_in_redis_with_ttl(self):
+ def test_stores_context_in_redis_with_ttl(self) -> None:
context_id = OAuthProxyService.create_proxy_context(
user_id="u1", tenant_id="t1", plugin_id="p1", provider="github"
)
assert context_id # non-empty UUID string
- from extensions.ext_redis import redis_client
+ redis_client = _redis_mock()
oauth_calls = _oauth_proxy_setex_calls(redis_client)
assert len(oauth_calls) == 1
@@ -41,50 +48,50 @@ class TestCreateProxyContext:
assert stored_data["plugin_id"] == "p1"
assert stored_data["provider"] == "github"
- def test_includes_credential_id_when_provided(self):
+ def test_includes_credential_id_when_provided(self) -> None:
OAuthProxyService.create_proxy_context(
user_id="u1", tenant_id="t1", plugin_id="p1", provider="github", credential_id="cred-1"
)
- from extensions.ext_redis import redis_client
+ redis_client = _redis_mock()
stored_data = json.loads(redis_client.setex.call_args[0][2])
assert stored_data["credential_id"] == "cred-1"
- def test_excludes_credential_id_when_none(self):
+ def test_excludes_credential_id_when_none(self) -> None:
OAuthProxyService.create_proxy_context(user_id="u1", tenant_id="t1", plugin_id="p1", provider="github")
- from extensions.ext_redis import redis_client
+ redis_client = _redis_mock()
stored_data = json.loads(redis_client.setex.call_args[0][2])
assert "credential_id" not in stored_data
- def test_includes_extra_data(self):
+ def test_includes_extra_data(self) -> None:
OAuthProxyService.create_proxy_context(
user_id="u1", tenant_id="t1", plugin_id="p1", provider="github", extra_data={"scope": "repo"}
)
- from extensions.ext_redis import redis_client
+ redis_client = _redis_mock()
stored_data = json.loads(redis_client.setex.call_args[0][2])
assert stored_data["scope"] == "repo"
class TestUseProxyContext:
- def test_raises_when_context_id_empty(self):
+ def test_raises_when_context_id_empty(self) -> None:
with pytest.raises(ValueError, match="context_id is required"):
OAuthProxyService.use_proxy_context("")
- def test_raises_when_context_not_found(self):
- from extensions.ext_redis import redis_client
+ def test_raises_when_context_not_found(self) -> None:
+ redis_client = _redis_mock()
redis_client.get.return_value = None
with pytest.raises(ValueError, match="context_id is invalid"):
OAuthProxyService.use_proxy_context("nonexistent-id")
- def test_returns_data_and_deletes_key(self):
- from extensions.ext_redis import redis_client
+ def test_returns_data_and_deletes_key(self) -> None:
+ redis_client = _redis_mock()
stored = {"user_id": "u1", "tenant_id": "t1", "plugin_id": "p1", "provider": "github"}
redis_client.get.return_value = json.dumps(stored).encode()
@@ -96,8 +103,8 @@ class TestUseProxyContext:
expected_key = "oauth_proxy_context:valid-id"
delete.assert_called_once_with(expected_key)
- def test_returns_context_with_credential_id(self):
- from extensions.ext_redis import redis_client
+ def test_returns_context_with_credential_id(self) -> None:
+ redis_client = _redis_mock()
stored = {
"user_id": "u1",
diff --git a/api/tests/unit_tests/services/plugin/test_plugin_migration.py b/api/tests/unit_tests/services/plugin/test_plugin_migration.py
index 068da9ba392..b4344ecfea9 100644
--- a/api/tests/unit_tests/services/plugin/test_plugin_migration.py
+++ b/api/tests/unit_tests/services/plugin/test_plugin_migration.py
@@ -1,4 +1,5 @@
import json
+from collections.abc import Callable
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
@@ -14,11 +15,13 @@ MIGRATION_MODULE = "services.plugin.plugin_migration"
@pytest.fixture(autouse=True)
-def _marketplace_enabled(config_overrides) -> None:
+def _marketplace_enabled(config_overrides: Callable[..., None]) -> None:
config_overrides(MARKETPLACE_ENABLED=True)
-def test_fetch_latest_package_identifier_returns_none_when_disabled(mocker: MockerFixture, config_overrides) -> None:
+def test_fetch_latest_package_identifier_returns_none_when_disabled(
+ mocker: MockerFixture, config_overrides: Callable[..., None]
+) -> None:
config_overrides(MARKETPLACE_ENABLED=False)
batch_fetch = mocker.patch("services.plugin.plugin_migration.marketplace.batch_fetch_plugin_manifests")
@@ -66,14 +69,14 @@ def test_extract_app_tables_checks_agent_mode_with_its_session(mocker: MockerFix
class TestHandlePluginInstanceInstall:
- def test_raises_when_disabled_and_map_nonempty(self, config_overrides) -> None:
+ def test_raises_when_disabled_and_map_nonempty(self, config_overrides: Callable[..., None]) -> None:
config_overrides(MARKETPLACE_ENABLED=False)
with pytest.raises(ValueError, match="Marketplace disabled"):
PluginMigration.handle_plugin_instance_install(
"tenant1", {"langgenius/openai": "langgenius/openai:1.0.0@abc"}
)
- def test_no_raise_when_disabled_and_map_empty(self, config_overrides) -> None:
+ def test_no_raise_when_disabled_and_map_empty(self, config_overrides: Callable[..., None]) -> None:
config_overrides(MARKETPLACE_ENABLED=False)
with patch(f"{MIGRATION_MODULE}.PluginInstaller") as mock_installer_cls:
mock_installer = MagicMock()
@@ -139,7 +142,7 @@ class TestHandlePluginInstanceInstall:
patch(f"{MIGRATION_MODULE}.PluginService.invalidate_plugin_model_providers_cache") as invalidate_cache,
):
mock_installer = MagicMock()
- mock_installer.list_plugins.return_value = []
+ mock_installer.list_plugins.return_value = list[object]()
mock_installer_cls.return_value = mock_installer
PluginMigration.install_plugins(str(extracted_plugins), str(output_file), workers=1)
@@ -165,7 +168,7 @@ class TestHandlePluginInstanceInstall:
patch(f"{MIGRATION_MODULE}.PluginService.invalidate_plugin_model_providers_cache"),
):
mock_installer = MagicMock()
- mock_installer.list_plugins.return_value = []
+ mock_installer.list_plugins.return_value = list[object]()
mock_installer_cls.return_value = mock_installer
PluginMigration.install_plugins(str(extracted_plugins), str(output_file), workers=1)
@@ -195,7 +198,7 @@ class TestHandlePluginInstanceInstall:
patch(f"{MIGRATION_MODULE}.PluginInstaller") as mock_installer_cls,
):
mock_installer = MagicMock()
- mock_installer.list_plugins.return_value = []
+ mock_installer.list_plugins.return_value = list[object]()
mock_installer_cls.return_value = mock_installer
PluginMigration.install_plugins(str(extracted_plugins), str(output_file), workers=1)
diff --git a/api/tests/unit_tests/services/plugin/test_plugin_service.py b/api/tests/unit_tests/services/plugin/test_plugin_service.py
index ff41c204069..11b38a39892 100644
--- a/api/tests/unit_tests/services/plugin/test_plugin_service.py
+++ b/api/tests/unit_tests/services/plugin/test_plugin_service.py
@@ -1,5 +1,6 @@
import datetime
import uuid
+from collections.abc import Callable, Iterator
from types import SimpleNamespace
from unittest.mock import MagicMock, Mock, call, patch
@@ -31,7 +32,7 @@ USER_ID = "33333333-3333-3333-3333-333333333333"
@pytest.fixture(autouse=True)
-def _plugin_config(config_overrides) -> None:
+def _plugin_config(config_overrides: Callable[..., None]) -> None:
config_overrides(
MARKETPLACE_ENABLED=True,
PLUGIN_MODEL_PROVIDERS_CACHE_TTL=86400,
@@ -41,7 +42,7 @@ def _plugin_config(config_overrides) -> None:
@pytest.fixture(autouse=True)
-def _clear_parsed_provider_cache():
+def _clear_parsed_provider_cache() -> Iterator[None]:
"""Keep the process-local provider cache isolated between tests."""
from core.plugin.plugin_service import PluginService
@@ -125,7 +126,7 @@ def _provider_generation_key(tenant_id: str) -> str:
class TestFetchLatestPluginVersion:
- def test_skips_marketplace_fetch_when_disabled(self, config_overrides) -> None:
+ def test_skips_marketplace_fetch_when_disabled(self, config_overrides: Callable[..., None]) -> None:
"""Cache misses stay None; marketplace is never called when disabled."""
config_overrides(MARKETPLACE_ENABLED=False)
with (
@@ -340,7 +341,9 @@ class TestPluginModelProviderCache:
call([cache_key]),
]
- def test_fetch_plugin_model_providers_bypasses_redis_when_cache_disabled(self, config_overrides) -> None:
+ def test_fetch_plugin_model_providers_bypasses_redis_when_cache_disabled(
+ self, config_overrides: Callable[..., None]
+ ) -> None:
"""With the cache disabled the daemon is the only source, and Redis is never touched."""
config_overrides(PLUGIN_MODEL_PROVIDERS_CACHE_ENABLED=False)
with patch(f"{MODULE}.redis_client") as redis_client:
@@ -361,7 +364,9 @@ class TestPluginModelProviderCache:
redis_client.setex.assert_not_called()
redis_client.lock.assert_not_called()
- def test_fetch_plugin_model_providers_resolves_missing_installation_source(self, config_overrides) -> None:
+ def test_fetch_plugin_model_providers_resolves_missing_installation_source(
+ self, config_overrides: Callable[..., None]
+ ) -> None:
config_overrides(PLUGIN_MODEL_PROVIDERS_CACHE_ENABLED=False)
provider = _build_plugin_model_provider(installation_source=None)
installation = SimpleNamespace(
@@ -731,7 +736,7 @@ class TestPluginModelProviderCache:
redis_client.get.return_value = None
redis_client.mget.return_value = [None]
client = Mock()
- client.fetch_model_providers.return_value = []
+ client.fetch_model_providers.return_value = list[object]()
from core.plugin.plugin_service import PluginService
@@ -748,7 +753,7 @@ class TestPluginModelProviderCache:
redis_client.get.side_effect = [None, None, "1"]
redis_client.mget.return_value = [None]
client = Mock()
- client.fetch_model_providers.return_value = []
+ client.fetch_model_providers.return_value = list[object]()
from core.plugin.plugin_service import PluginService
@@ -1406,7 +1411,7 @@ class TestPluginModelProviderCacheInvalidation:
patch(f"{MODULE}.PluginService.invalidate_plugin_model_providers_cache") as invalidate_cache,
):
installer = installer_cls.return_value
- installer.list_plugins.return_value = []
+ installer.list_plugins.return_value = list[object]()
installer.uninstall.return_value = True
from core.plugin.plugin_service import PluginService