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): replace test fixture side-effect imports (#34421)

99cd406d2794ef
diff --git a/api/.ruff.toml b/api/.ruff.toml
index 4b1252a8613..2a825f1ef05 100644
--- a/api/.ruff.toml
+++ b/api/.ruff.toml
@@ -115,12 +115,6 @@ ignore = [
"controllers/console/human_input_form.py" = ["TID251"]
"controllers/web/human_input_form.py" = ["TID251"]
-[lint.pyflakes]
-allowed-unused-imports = [
- "tests.integration_tests",
- "tests.unit_tests",
-]
-
[lint.flake8-tidy-imports]
[lint.flake8-tidy-imports.banned-api."flask_restx.reqparse"]
diff --git a/api/tests/integration_tests/plugin/__mock/http.py b/api/tests/integration_tests/plugin/__mock/http.py
index d5cf47e2c24..b39e4a8e762 100644
--- a/api/tests/integration_tests/plugin/__mock/http.py
+++ b/api/tests/integration_tests/plugin/__mock/http.py
@@ -4,23 +4,28 @@ from typing import Literal
import httpx
import pytest
-from core.plugin.entities.plugin_daemon import PluginDaemonBasicResponse
+from core.plugin.entities.plugin_daemon import PluginDaemonBasicResponse, PluginToolProviderEntity
from core.tools.entities.common_entities import I18nObject
-from core.tools.entities.tool_entities import ToolProviderEntity, ToolProviderIdentity
+from core.tools.entities.tool_entities import ToolProviderEntityWithPlugin, ToolProviderIdentity
class MockedHttp:
@classmethod
- def list_tools(cls) -> list[ToolProviderEntity]:
+ def list_tools(cls) -> list[PluginToolProviderEntity]:
return [
- ToolProviderEntity(
- identity=ToolProviderIdentity(
- author="Yeuoly",
- name="Yeuoly",
- description=I18nObject(en_US="Yeuoly"),
- icon="ssss.svg",
- label=I18nObject(en_US="Yeuoly"),
- )
+ PluginToolProviderEntity(
+ provider="Yeuoly",
+ plugin_unique_identifier="langgenius/yeuoly:0.0.1@mock",
+ plugin_id="mock-plugin",
+ declaration=ToolProviderEntityWithPlugin(
+ identity=ToolProviderIdentity(
+ author="Yeuoly",
+ name="Yeuoly",
+ description=I18nObject(en_US="Yeuoly"),
+ icon="ssss.svg",
+ label=I18nObject(en_US="Yeuoly"),
+ )
+ ),
)
]
@@ -33,7 +38,7 @@ class MockedHttp:
"""
request = httpx.Request(method, url)
if url.endswith("/tools"):
- content = PluginDaemonBasicResponse[list[ToolProviderEntity]](
+ content = PluginDaemonBasicResponse[list[PluginToolProviderEntity]](
code=0, message="success", data=cls.list_tools()
).model_dump_json()
else:
diff --git a/api/tests/integration_tests/plugin/tools/test_fetch_all_tools.py b/api/tests/integration_tests/plugin/tools/test_fetch_all_tools.py
index b6d583e3389..9a4450a454f 100644
--- a/api/tests/integration_tests/plugin/tools/test_fetch_all_tools.py
+++ b/api/tests/integration_tests/plugin/tools/test_fetch_all_tools.py
@@ -1,5 +1,6 @@
from core.plugin.impl.tool import PluginToolManager
-from tests.integration_tests.plugin.__mock.http import setup_http_mock
+
+pytest_plugins = ("tests.integration_tests.plugin.__mock.http",)
def test_fetch_all_plugin_tools(setup_http_mock):
diff --git a/api/tests/integration_tests/tools/api_tool/test_api_tool.py b/api/tests/integration_tests/tools/api_tool/test_api_tool.py
index e6375302651..9079aa7d6d2 100644
--- a/api/tests/integration_tests/tools/api_tool/test_api_tool.py
+++ b/api/tests/integration_tests/tools/api_tool/test_api_tool.py
@@ -3,7 +3,8 @@ from core.tools.custom_tool.tool import ApiTool
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_bundle import ApiToolBundle
from core.tools.entities.tool_entities import ToolEntity, ToolIdentity
-from tests.integration_tests.tools.__mock.http import setup_http_mock
+
+pytest_plugins = ("tests.integration_tests.tools.__mock.http",)
tool_bundle = {
"server_url": "http://www.example.com/{path_param}",
diff --git a/api/tests/integration_tests/vdb/analyticdb/test_analyticdb.py b/api/tests/integration_tests/vdb/analyticdb/test_analyticdb.py
index 5dd4754e8ef..09815238097 100644
--- a/api/tests/integration_tests/vdb/analyticdb/test_analyticdb.py
+++ b/api/tests/integration_tests/vdb/analyticdb/test_analyticdb.py
@@ -1,7 +1,9 @@
from core.rag.datasource.vdb.analyticdb.analyticdb_vector import AnalyticdbVector
from core.rag.datasource.vdb.analyticdb.analyticdb_vector_openapi import AnalyticdbVectorOpenAPIConfig
from core.rag.datasource.vdb.analyticdb.analyticdb_vector_sql import AnalyticdbVectorBySqlConfig
-from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, setup_mock_redis
+from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest
+
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
class AnalyticdbVectorTest(AbstractVectorTest):
diff --git a/api/tests/integration_tests/vdb/baidu/test_baidu.py b/api/tests/integration_tests/vdb/baidu/test_baidu.py
index 25989958d99..716f88af672 100644
--- a/api/tests/integration_tests/vdb/baidu/test_baidu.py
+++ b/api/tests/integration_tests/vdb/baidu/test_baidu.py
@@ -1,6 +1,10 @@
from core.rag.datasource.vdb.baidu.baidu_vector import BaiduConfig, BaiduVector
-from tests.integration_tests.vdb.__mock.baiduvectordb import setup_baiduvectordb_mock
-from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text, setup_mock_redis
+from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text
+
+pytest_plugins = (
+ "tests.integration_tests.vdb.test_vector_store",
+ "tests.integration_tests.vdb.__mock.baiduvectordb",
+)
class BaiduVectorTest(AbstractVectorTest):
diff --git a/api/tests/integration_tests/vdb/chroma/test_chroma.py b/api/tests/integration_tests/vdb/chroma/test_chroma.py
index ac7b5cbda45..52beba9979d 100644
--- a/api/tests/integration_tests/vdb/chroma/test_chroma.py
+++ b/api/tests/integration_tests/vdb/chroma/test_chroma.py
@@ -4,9 +4,10 @@ from core.rag.datasource.vdb.chroma.chroma_vector import ChromaConfig, ChromaVec
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
get_example_text,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class ChromaVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/couchbase/test_couchbase.py b/api/tests/integration_tests/vdb/couchbase/test_couchbase.py
index eef1ee4e759..0371f042330 100644
--- a/api/tests/integration_tests/vdb/couchbase/test_couchbase.py
+++ b/api/tests/integration_tests/vdb/couchbase/test_couchbase.py
@@ -4,9 +4,10 @@ import time
from core.rag.datasource.vdb.couchbase.couchbase_vector import CouchbaseConfig, CouchbaseVector
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
def wait_for_healthy_container(service_name="couchbase-server", timeout=300):
start_time = time.time()
diff --git a/api/tests/integration_tests/vdb/elasticsearch/test_elasticsearch.py b/api/tests/integration_tests/vdb/elasticsearch/test_elasticsearch.py
index a5ff5b9e822..970d2cce1ae 100644
--- a/api/tests/integration_tests/vdb/elasticsearch/test_elasticsearch.py
+++ b/api/tests/integration_tests/vdb/elasticsearch/test_elasticsearch.py
@@ -1,9 +1,10 @@
from core.rag.datasource.vdb.elasticsearch.elasticsearch_vector import ElasticSearchConfig, ElasticSearchVector
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class ElasticSearchVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/hologres/test_hologres.py b/api/tests/integration_tests/vdb/hologres/test_hologres.py
index ff2be88ef18..d81e18841e0 100644
--- a/api/tests/integration_tests/vdb/hologres/test_hologres.py
+++ b/api/tests/integration_tests/vdb/hologres/test_hologres.py
@@ -6,8 +6,12 @@ from holo_search_sdk.types import BaseQuantizationType, DistanceType, TokenizerT
from core.rag.datasource.vdb.hologres.hologres_vector import HologresVector, HologresVectorConfig
from core.rag.models.document import Document
-from tests.integration_tests.vdb.__mock.hologres import setup_hologres_mock
-from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text, setup_mock_redis
+from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text
+
+pytest_plugins = (
+ "tests.integration_tests.vdb.test_vector_store",
+ "tests.integration_tests.vdb.__mock.hologres",
+)
MOCK = os.getenv("MOCK_SWITCH", "false").lower() == "true"
diff --git a/api/tests/integration_tests/vdb/huawei/test_huawei_cloud.py b/api/tests/integration_tests/vdb/huawei/test_huawei_cloud.py
index 943b2bc877a..01f511358af 100644
--- a/api/tests/integration_tests/vdb/huawei/test_huawei_cloud.py
+++ b/api/tests/integration_tests/vdb/huawei/test_huawei_cloud.py
@@ -1,6 +1,10 @@
from core.rag.datasource.vdb.huawei.huawei_cloud_vector import HuaweiCloudVector, HuaweiCloudVectorConfig
-from tests.integration_tests.vdb.__mock.huaweicloudvectordb import setup_client_mock
-from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text, setup_mock_redis
+from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text
+
+pytest_plugins = (
+ "tests.integration_tests.vdb.test_vector_store",
+ "tests.integration_tests.vdb.__mock.huaweicloudvectordb",
+)
class HuaweiCloudVectorTest(AbstractVectorTest):
diff --git a/api/tests/integration_tests/vdb/iris/test_iris.py b/api/tests/integration_tests/vdb/iris/test_iris.py
index 49f6857743e..4b2da8387bd 100644
--- a/api/tests/integration_tests/vdb/iris/test_iris.py
+++ b/api/tests/integration_tests/vdb/iris/test_iris.py
@@ -3,9 +3,10 @@
from core.rag.datasource.vdb.iris.iris_vector import IrisVector, IrisVectorConfig
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class IrisVectorTest(AbstractVectorTest):
"""Test suite for IRIS vector store implementation."""
diff --git a/api/tests/integration_tests/vdb/lindorm/test_lindorm.py b/api/tests/integration_tests/vdb/lindorm/test_lindorm.py
index 6708ab80956..b24498fdfdd 100644
--- a/api/tests/integration_tests/vdb/lindorm/test_lindorm.py
+++ b/api/tests/integration_tests/vdb/lindorm/test_lindorm.py
@@ -1,7 +1,9 @@
import os
from core.rag.datasource.vdb.lindorm.lindorm_vector import LindormVectorStore, LindormVectorStoreConfig
-from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, setup_mock_redis
+from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest
+
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
class Config:
diff --git a/api/tests/integration_tests/vdb/matrixone/test_matrixone.py b/api/tests/integration_tests/vdb/matrixone/test_matrixone.py
index c4056db63e2..fe592f6699c 100644
--- a/api/tests/integration_tests/vdb/matrixone/test_matrixone.py
+++ b/api/tests/integration_tests/vdb/matrixone/test_matrixone.py
@@ -1,9 +1,10 @@
from core.rag.datasource.vdb.matrixone.matrixone_vector import MatrixoneConfig, MatrixoneVector
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class MatrixoneVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/milvus/test_milvus.py b/api/tests/integration_tests/vdb/milvus/test_milvus.py
index 0e13f9369e8..b5fc4b4d109 100644
--- a/api/tests/integration_tests/vdb/milvus/test_milvus.py
+++ b/api/tests/integration_tests/vdb/milvus/test_milvus.py
@@ -2,9 +2,10 @@ from core.rag.datasource.vdb.milvus.milvus_vector import MilvusConfig, MilvusVec
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
get_example_text,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class MilvusVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/myscale/test_myscale.py b/api/tests/integration_tests/vdb/myscale/test_myscale.py
index 55b2fde4276..74cefad2af7 100644
--- a/api/tests/integration_tests/vdb/myscale/test_myscale.py
+++ b/api/tests/integration_tests/vdb/myscale/test_myscale.py
@@ -1,9 +1,10 @@
from core.rag.datasource.vdb.myscale.myscale_vector import MyScaleConfig, MyScaleVector
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class MyScaleVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/oceanbase/test_oceanbase.py b/api/tests/integration_tests/vdb/oceanbase/test_oceanbase.py
index 2db6732354b..410de2c5ad2 100644
--- a/api/tests/integration_tests/vdb/oceanbase/test_oceanbase.py
+++ b/api/tests/integration_tests/vdb/oceanbase/test_oceanbase.py
@@ -6,9 +6,10 @@ from core.rag.datasource.vdb.oceanbase.oceanbase_vector import (
)
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
@pytest.fixture
def oceanbase_vector():
diff --git a/api/tests/integration_tests/vdb/opengauss/test_opengauss.py b/api/tests/integration_tests/vdb/opengauss/test_opengauss.py
index 338077bbff3..78436a19eef 100644
--- a/api/tests/integration_tests/vdb/opengauss/test_opengauss.py
+++ b/api/tests/integration_tests/vdb/opengauss/test_opengauss.py
@@ -5,9 +5,10 @@ import psycopg2
from core.rag.datasource.vdb.opengauss.opengauss import OpenGauss, OpenGaussConfig
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class OpenGaussTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/oracle/test_oraclevector.py b/api/tests/integration_tests/vdb/oracle/test_oraclevector.py
index 76e8b7bccd3..8920dc97ebb 100644
--- a/api/tests/integration_tests/vdb/oracle/test_oraclevector.py
+++ b/api/tests/integration_tests/vdb/oracle/test_oraclevector.py
@@ -3,9 +3,10 @@ from core.rag.models.document import Document
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
get_example_text,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class OracleVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/pgvecto_rs/test_pgvecto_rs.py b/api/tests/integration_tests/vdb/pgvecto_rs/test_pgvecto_rs.py
index 6497f47deb9..6210613d421 100644
--- a/api/tests/integration_tests/vdb/pgvecto_rs/test_pgvecto_rs.py
+++ b/api/tests/integration_tests/vdb/pgvecto_rs/test_pgvecto_rs.py
@@ -2,9 +2,10 @@ from core.rag.datasource.vdb.pgvecto_rs.pgvecto_rs import PGVectoRS, PgvectoRSCo
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
get_example_text,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class PGVectoRSVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/pgvector/test_pgvector.py b/api/tests/integration_tests/vdb/pgvector/test_pgvector.py
index 3d2cfde5d1d..4fdeca5a3a8 100644
--- a/api/tests/integration_tests/vdb/pgvector/test_pgvector.py
+++ b/api/tests/integration_tests/vdb/pgvector/test_pgvector.py
@@ -1,10 +1,10 @@
from core.rag.datasource.vdb.pgvector.pgvector import PGVector, PGVectorConfig
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- get_example_text,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class PGVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/pyvastbase/test_vastbase_vector.py b/api/tests/integration_tests/vdb/pyvastbase/test_vastbase_vector.py
index 02931fef5a2..a47f13625cd 100644
--- a/api/tests/integration_tests/vdb/pyvastbase/test_vastbase_vector.py
+++ b/api/tests/integration_tests/vdb/pyvastbase/test_vastbase_vector.py
@@ -1,9 +1,10 @@
from core.rag.datasource.vdb.pyvastbase.vastbase_vector import VastbaseVector, VastbaseVectorConfig
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class VastbaseVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/qdrant/test_qdrant.py b/api/tests/integration_tests/vdb/qdrant/test_qdrant.py
index a2bf10001a9..709cc2e14ef 100644
--- a/api/tests/integration_tests/vdb/qdrant/test_qdrant.py
+++ b/api/tests/integration_tests/vdb/qdrant/test_qdrant.py
@@ -4,9 +4,10 @@ from core.rag.datasource.vdb.qdrant.qdrant_vector import QdrantConfig, QdrantVec
from core.rag.models.document import Document
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class QdrantVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/tablestore/test_tablestore.py b/api/tests/integration_tests/vdb/tablestore/test_tablestore.py
index aebf3fbda10..b60e26a881d 100644
--- a/api/tests/integration_tests/vdb/tablestore/test_tablestore.py
+++ b/api/tests/integration_tests/vdb/tablestore/test_tablestore.py
@@ -12,9 +12,10 @@ from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
get_example_document,
get_example_text,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class TableStoreVectorTest(AbstractVectorTest):
def __init__(self, normalize_full_text_score: bool = False):
diff --git a/api/tests/integration_tests/vdb/tcvectordb/test_tencent.py b/api/tests/integration_tests/vdb/tcvectordb/test_tencent.py
index 9227bbdcd65..3d6deff2a06 100644
--- a/api/tests/integration_tests/vdb/tcvectordb/test_tencent.py
+++ b/api/tests/integration_tests/vdb/tcvectordb/test_tencent.py
@@ -1,8 +1,12 @@
from unittest.mock import MagicMock
from core.rag.datasource.vdb.tencent.tencent_vector import TencentConfig, TencentVector
-from tests.integration_tests.vdb.__mock.tcvectordb import setup_tcvectordb_mock
-from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text, setup_mock_redis
+from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text
+
+pytest_plugins = (
+ "tests.integration_tests.vdb.test_vector_store",
+ "tests.integration_tests.vdb.__mock.tcvectordb",
+)
mock_client = MagicMock()
mock_client.list_databases.return_value = [{"name": "test"}]
diff --git a/api/tests/integration_tests/vdb/tidb_vector/test_tidb_vector.py b/api/tests/integration_tests/vdb/tidb_vector/test_tidb_vector.py
index dec63c64761..14c6d1c67c5 100644
--- a/api/tests/integration_tests/vdb/tidb_vector/test_tidb_vector.py
+++ b/api/tests/integration_tests/vdb/tidb_vector/test_tidb_vector.py
@@ -2,7 +2,9 @@ import pytest
from core.rag.datasource.vdb.tidb_vector.tidb_vector import TiDBVector, TiDBVectorConfig
from models.dataset import Document
-from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text, setup_mock_redis
+from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text
+
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
@pytest.fixture
diff --git a/api/tests/integration_tests/vdb/upstash/test_upstash_vector.py b/api/tests/integration_tests/vdb/upstash/test_upstash_vector.py
index 23470474ff6..8cea0a05eb6 100644
--- a/api/tests/integration_tests/vdb/upstash/test_upstash_vector.py
+++ b/api/tests/integration_tests/vdb/upstash/test_upstash_vector.py
@@ -1,8 +1,9 @@
from core.rag.datasource.vdb.upstash.upstash_vector import UpstashVector, UpstashVectorConfig
from core.rag.models.document import Document
-from tests.integration_tests.vdb.__mock.upstashvectordb import setup_upstashvector_mock
from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text
+pytest_plugins = ("tests.integration_tests.vdb.__mock.upstashvectordb",)
+
class UpstashVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/vdb/vikingdb/test_vikingdb.py b/api/tests/integration_tests/vdb/vikingdb/test_vikingdb.py
index 2572012ea03..56311acd25e 100644
--- a/api/tests/integration_tests/vdb/vikingdb/test_vikingdb.py
+++ b/api/tests/integration_tests/vdb/vikingdb/test_vikingdb.py
@@ -1,6 +1,10 @@
from core.rag.datasource.vdb.vikingdb.vikingdb_vector import VikingDBConfig, VikingDBVector
-from tests.integration_tests.vdb.__mock.vikingdb import setup_vikingdb_mock
-from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text, setup_mock_redis
+from tests.integration_tests.vdb.test_vector_store import AbstractVectorTest, get_example_text
+
+pytest_plugins = (
+ "tests.integration_tests.vdb.test_vector_store",
+ "tests.integration_tests.vdb.__mock.vikingdb",
+)
class VikingDBVectorTest(AbstractVectorTest):
diff --git a/api/tests/integration_tests/vdb/weaviate/test_weaviate.py b/api/tests/integration_tests/vdb/weaviate/test_weaviate.py
index a6f55420d31..a1d9850979f 100644
--- a/api/tests/integration_tests/vdb/weaviate/test_weaviate.py
+++ b/api/tests/integration_tests/vdb/weaviate/test_weaviate.py
@@ -1,9 +1,10 @@
from core.rag.datasource.vdb.weaviate.weaviate_vector import WeaviateConfig, WeaviateVector
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
- setup_mock_redis,
)
+pytest_plugins = ("tests.integration_tests.vdb.test_vector_store",)
+
class WeaviateVectorTest(AbstractVectorTest):
def __init__(self):
diff --git a/api/tests/integration_tests/workflow/nodes/test_code.py b/api/tests/integration_tests/workflow/nodes/test_code.py
index ce0c8bf8ca8..4f41396c22b 100644
--- a/api/tests/integration_tests/workflow/nodes/test_code.py
+++ b/api/tests/integration_tests/workflow/nodes/test_code.py
@@ -13,9 +13,10 @@ from configs import dify_config
from core.app.entities.app_invoke_entities import InvokeFrom, UserFrom
from core.workflow.node_factory import DifyNodeFactory
from core.workflow.system_variables import build_system_variables
-from tests.integration_tests.workflow.nodes.__mock.code_executor import setup_code_executor_mock
from tests.workflow_test_utils import build_test_graph_init_params
+pytest_plugins = ("tests.integration_tests.workflow.nodes.__mock.code_executor",)
+
CODE_MAX_STRING_LENGTH = dify_config.CODE_MAX_STRING_LENGTH
diff --git a/api/tests/integration_tests/workflow/nodes/test_http.py b/api/tests/integration_tests/workflow/nodes/test_http.py
index ce18486fafc..b1f937e7388 100644
--- a/api/tests/integration_tests/workflow/nodes/test_http.py
+++ b/api/tests/integration_tests/workflow/nodes/test_http.py
@@ -16,9 +16,10 @@ from core.tools.tool_file_manager import ToolFileManager
from core.workflow.node_factory import DifyNodeFactory
from core.workflow.node_runtime import DifyFileReferenceFactory
from core.workflow.system_variables import build_system_variables
-from tests.integration_tests.workflow.nodes.__mock.http import setup_http_mock
from tests.workflow_test_utils import build_test_graph_init_params
+pytest_plugins = ("tests.integration_tests.workflow.nodes.__mock.http",)
+
HTTP_REQUEST_CONFIG = HttpRequestNodeConfig(
max_connect_timeout=dify_config.HTTP_REQUEST_MAX_CONNECT_TIMEOUT,
max_read_timeout=dify_config.HTTP_REQUEST_MAX_READ_TIMEOUT,
diff --git a/api/tests/integration_tests/workflow/nodes/test_parameter_extractor.py b/api/tests/integration_tests/workflow/nodes/test_parameter_extractor.py
index 3bf44df349c..fe512c25856 100644
--- a/api/tests/integration_tests/workflow/nodes/test_parameter_extractor.py
+++ b/api/tests/integration_tests/workflow/nodes/test_parameter_extractor.py
@@ -17,8 +17,7 @@ from extensions.ext_database import db
from tests.integration_tests.workflow.nodes.__mock.model import get_mocked_fetch_model_instance
from tests.workflow_test_utils import build_test_graph_init_params
-"""FOR MOCK FIXTURES, DO NOT REMOVE"""
-from tests.integration_tests.model_runtime.__mock.plugin_daemon import setup_model_mock
+pytest_plugins = ("tests.integration_tests.model_runtime.__mock.plugin_daemon",)
def get_mocked_fetch_memory(memory_text: str):
diff --git a/api/tests/unit_tests/oss/aliyun_oss/aliyun_oss/test_aliyun_oss.py b/api/tests/unit_tests/oss/aliyun_oss/aliyun_oss/test_aliyun_oss.py
index 10388a88809..52abfdd72ed 100644
--- a/api/tests/unit_tests/oss/aliyun_oss/aliyun_oss/test_aliyun_oss.py
+++ b/api/tests/unit_tests/oss/aliyun_oss/aliyun_oss/test_aliyun_oss.py
@@ -4,13 +4,14 @@ import pytest
from oss2 import Auth
from extensions.storage.aliyun_oss_storage import AliyunOssStorage
-from tests.unit_tests.oss.__mock.aliyun_oss import setup_aliyun_oss_mock
from tests.unit_tests.oss.__mock.base import (
BaseStorageTest,
get_example_bucket,
get_example_folder,
)
+pytest_plugins = ("tests.unit_tests.oss.__mock.aliyun_oss",)
+
class TestAliyunOss(BaseStorageTest):
@pytest.fixture(autouse=True)
diff --git a/api/tests/unit_tests/oss/tencent_cos/test_tencent_cos.py b/api/tests/unit_tests/oss/tencent_cos/test_tencent_cos.py
index d54116555ee..2802a2f1e39 100644
--- a/api/tests/unit_tests/oss/tencent_cos/test_tencent_cos.py
+++ b/api/tests/unit_tests/oss/tencent_cos/test_tencent_cos.py
@@ -8,7 +8,8 @@ from tests.unit_tests.oss.__mock.base import (
BaseStorageTest,
get_example_bucket,
)
-from tests.unit_tests.oss.__mock.tencent_cos import setup_tencent_cos_mock
+
+pytest_plugins = ("tests.unit_tests.oss.__mock.tencent_cos",)
class TestTencentCos(BaseStorageTest):
diff --git a/api/tests/unit_tests/oss/volcengine_tos/test_volcengine_tos.py b/api/tests/unit_tests/oss/volcengine_tos/test_volcengine_tos.py
index a06623a69e4..8adea888115 100644
--- a/api/tests/unit_tests/oss/volcengine_tos/test_volcengine_tos.py
+++ b/api/tests/unit_tests/oss/volcengine_tos/test_volcengine_tos.py
@@ -8,7 +8,8 @@ from tests.unit_tests.oss.__mock.base import (
BaseStorageTest,
get_example_bucket,
)
-from tests.unit_tests.oss.__mock.volcengine_tos import setup_volcengine_tos_mock
+
+pytest_plugins = ("tests.unit_tests.oss.__mock.volcengine_tos",)
class TestVolcengineTos(BaseStorageTest):