Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

ci(sdk): restore Python SDK p2 tests (#21687)

Sbaaoui Idriss072038113bf9
diff --git a/.github/workflows/sep-tests.yml b/.github/workflows/sep-tests.yml
index 7fd429e3dd..b82265b668 100644
--- a/.github/workflows/sep-tests.yml
+++ b/.github/workflows/sep-tests.yml
@@ -690,6 +690,16 @@ jobs:
fi
./build.sh --test-integration-go -timeout 60m ./test/api 2>&1 | tee "${ARTIFACTS_DIR}/infinity_go_api_test.log"
+ - name: Run Python SDK integration tests
+ if: ${{ env.HAS_GO == 'true' }}
+ env:
+ RAGFLOW_SDK_CI: "1"
+ run: |
+ set -euo pipefail
+ export http_proxy="" https_proxy="" no_proxy="" HTTP_PROXY="" HTTPS_PROXY="" NO_PROXY=""
+ uv pip install sdk/python
+ uv run --no-sync python -m pytest -s --tb=short --level=p2 test/testcases/test_sdk_api 2>&1 | tee "${ARTIFACTS_DIR}/infinity_sdk_test.log"
+
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
if: ${{ !cancelled() }}
@@ -1251,6 +1261,16 @@ jobs:
fi
./build.sh --test-integration-go -timeout 60m ./test/api 2>&1 | tee "${ARTIFACTS_DIR}/es_go_api_test.log"
+ - name: Run Python SDK integration tests
+ if: ${{ env.HAS_GO == 'true' }}
+ env:
+ RAGFLOW_SDK_CI: "1"
+ run: |
+ set -euo pipefail
+ export http_proxy="" https_proxy="" no_proxy="" HTTP_PROXY="" HTTPS_PROXY="" NO_PROXY=""
+ uv pip install sdk/python
+ uv run --no-sync python -m pytest -s --tb=short --level=p2 test/testcases/test_sdk_api 2>&1 | tee "${ARTIFACTS_DIR}/es_sdk_test.log"
+
- name: Collect ragflow log Elasticsearch
if: ${{ !cancelled() }}
# Keep this step self-sufficient: rebuild the artifacts path instead of
diff --git a/test/testcases/test_sdk_api/common.py b/test/testcases/test_sdk_api/common.py
index 5b48ac2277..03d7dda818 100644
--- a/test/testcases/test_sdk_api/common.py
+++ b/test/testcases/test_sdk_api/common.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,20 +16,13 @@
from pathlib import Path
-import pytest
-from configs import IS_GO_PROXY
from ragflow_sdk import Chat, Chunk, DataSet, Document, RAGFlow, Session
-from utils.file_utils import create_txt_file
+from test.testcases.utils.file_utils import create_txt_file
REST_API_MAX_PAGE_SIZE = 100
-def _skip_missing_go_document_metadata(error: Exception) -> None:
- if IS_GO_PROXY and "Unknown column 'meta_fields'" in str(error):
- pytest.skip("Go deployment database schema is missing document.meta_fields")
-
-
def list_all_documents(dataset: DataSet, *, limit: int | None = None, page_size: int = REST_API_MAX_PAGE_SIZE) -> list[Document]:
page_size = min(page_size, REST_API_MAX_PAGE_SIZE)
documents: list[Document] = []
@@ -91,11 +84,7 @@ def bulk_upload_documents(dataset: DataSet, num: int, tmp_path: Path) -> list[Do
blob = f.read()
document_infos.append({"display_name": fp.name, "blob": blob})
- try:
- return dataset.upload_documents(document_infos)
- except Exception as error:
- _skip_missing_go_document_metadata(error)
- raise
+ return dataset.upload_documents(document_infos)
def delete_all_documents(dataset: DataSet, *, page_size: int = 100) -> None:
diff --git a/test/testcases/test_sdk_api/conftest.py b/test/testcases/test_sdk_api/conftest.py
index 545af42c09..cb33c72cfb 100644
--- a/test/testcases/test_sdk_api/conftest.py
+++ b/test/testcases/test_sdk_api/conftest.py
@@ -14,11 +14,14 @@
# limitations under the License.
#
+import os
from pathlib import Path
+from uuid import uuid4
from time import sleep
import pytest
-from common import (
+import requests
+from test.testcases.test_sdk_api.common import (
batch_add_chunks,
batch_create_chat_assistants,
batch_create_datasets,
@@ -28,11 +31,11 @@ from common import (
delete_all_datasets,
delete_all_sessions,
)
-from configs import HOST_ADDRESS, IS_GO_PROXY, VERSION
+from test.testcases.configs import HOST_ADDRESS, PASSWORD, VERSION
from pytest import FixtureRequest
from ragflow_sdk import Chat, Chunk, DataSet, Document, RAGFlow
-from utils import wait_for
-from utils.file_utils import (
+from test.testcases.utils import wait_for
+from test.testcases.utils.file_utils import (
create_docx_file,
create_eml_file,
create_excel_file,
@@ -46,47 +49,164 @@ from utils.file_utils import (
)
-GO_ONLY_PATH_SKIPS = {
- "test_file_management_within_dataset/test_download_document.py::test_file_type_validation": "Go deployment database schema is missing document.meta_fields",
- "test_file_management_within_dataset/test_upload_documents.py": "Go deployment database schema is missing document.meta_fields",
- "test_dataset_mangement/test_create_dataset.py::TestDatasetCreate::test_parser_config_invalid": "Go dataset parser_config only validates serialized size, not individual fields",
- "test_dataset_mangement/test_create_dataset.py::TestDatasetCreate::test_parser_config_empty": "Go dataset creation does not preserve an explicit empty parser_config",
- "test_dataset_mangement/test_create_dataset.py::TestDatasetCreate::test_parser_config_unset": "Go dataset creation does not return the SDK parser_config contract",
- "test_dataset_mangement/test_create_dataset.py::TestParserConfigBugFix": "Go dataset parser_config defaults do not match the SDK contract",
- "test_dataset_mangement/test_update_dataset.py::TestDatasetUpdate::test_parser_config": "Go dataset updates do not return the SDK parser_config contract",
- "test_dataset_mangement/test_update_dataset.py::TestDatasetUpdate::test_parser_config_invalid": "Go dataset parser_config only validates serialized size, not individual fields",
- "test_dataset_mangement/test_update_dataset.py::TestDatasetUpdate::test_parser_config_empty": "Go dataset update ignores an explicit empty parser_config",
- "test_dataset_mangement/test_update_dataset.py::TestDatasetUpdate::test_field_unsupported": "Go dataset update ignores unsupported fields",
- "test_dataset_mangement/test_update_dataset.py::TestDatasetUpdate::test_pagerank": "Go dataset update does not persist pagerank",
- "test_dataset_mangement/test_update_dataset.py::TestDatasetUpdate::test_pagerank_set_to_0": "Go dataset update does not persist pagerank",
- "test_dataset_mangement/test_list_datasets.py::TestDatasetsList::test_page_invalid": "Go dataset list normalizes invalid page values instead of rejecting them",
- "test_dataset_mangement/test_list_datasets.py::TestDatasetsList::test_page_size_invalid": "Go dataset list normalizes invalid page_size values instead of rejecting them",
- "test_dataset_mangement/test_list_datasets.py::TestDatasetsList::test_name": "Go dataset list does not apply the name filter",
- "test_dataset_mangement/test_list_datasets.py::TestDatasetsList::test_id": "Go dataset list does not apply the id filter",
- "test_dataset_mangement/test_list_datasets.py::TestDatasetsList::test_id_empty": "Go dataset list accepts an empty id instead of rejecting it",
- "test_dataset_mangement/test_list_datasets.py::TestDatasetsList::test_name_and_id": "Go dataset list does not combine name and id filters",
- "test_message_management/test_add_message.py::TestAddRawMessage": "Go built-in embedding uses an unavailable localhost:6380 endpoint",
- "test_message_management/test_add_message.py::TestAddMultipleTypeMessage": "Go built-in embedding uses an unavailable localhost:6380 endpoint",
- "test_message_management/test_add_message.py::TestAddToMultipleMemory": "Go built-in embedding uses an unavailable localhost:6380 endpoint",
- "test_message_management/test_forget_message.py::TestForgetMessage": "Go built-in embedding uses an unavailable localhost:6380 endpoint",
- "test_message_management/test_get_message_content.py::TestGetMessageContent": "Go built-in embedding uses an unavailable localhost:6380 endpoint",
- "test_message_management/test_get_recent_message.py::TestGetRecentMessage": "Go built-in embedding uses an unavailable localhost:6380 endpoint",
- "test_message_management/test_list_message.py::TestMessageList": "Go built-in embedding uses an unavailable localhost:6380 endpoint",
- "test_message_management/test_search_message.py::TestSearchMessage": "Go built-in embedding uses an unavailable localhost:6380 endpoint",
- "test_message_management/test_update_message_status.py::TestUpdateMessageStatus": "Go built-in embedding uses an unavailable localhost:6380 endpoint",
-}
-
-
-def pytest_collection_modifyitems(items):
- if not IS_GO_PROXY:
+def pytest_configure(config):
+ config.addinivalue_line("markers", "integration: requires a disposable Go backend and dedicated test tenant")
+ # SDK folders contain duplicate module names and must keep distinct imports.
+ config.option.importmode = "importlib"
+ config._sdk_ci_environments = {}
+ config._sdk_ci_environment = pytest.MonkeyPatch()
+
+
+EMBEDDING = "BAAI/bge-small-en-v1.5@Local@Builtin"
+CHAT = "glm-4-flash@CI@ZHIPU-AI"
+UPDATE_CHAT = "glm-4-flashx@CI@ZHIPU-AI"
+RERANK = "BAAI/bge-reranker-v2-m3@CI@SILICONFLOW"
+
+
+class _API:
+ def __init__(self, base_url):
+ self.base_url = base_url.rstrip("/") + "/api/v1"
+ self.session = requests.Session()
+
+ def call(self, method, path, body=None):
+ # Never print response bodies: provider errors may contain credentials.
+ try:
+ response = self.session.request(method, self.base_url + path, json=body, timeout=120)
+ payload = response.json()
+ if response.status_code != 200 or payload.get("code") != 0:
+ raise RuntimeError(f"SDK environment setup failed: {method} {path} (HTTP {response.status_code}, API {payload.get('code')})")
+ except (requests.RequestException, ValueError):
+ raise RuntimeError(f"SDK environment setup failed: {method} {path}") from None
+ return payload.get("data"), response.headers
+
+ def close(self):
+ self.session.close()
+
+
+def _tenant(base_url):
+ api = _API(base_url)
+ try:
+ password = PASSWORD
+ account = {"email": f"sdk-{uuid4().hex}@example.org", "nickname": "SDK CI", "password": password}
+ api.call("POST", "/users", account)
+ profile, headers = api.call("POST", "/auth/login", {"email": account["email"], "password": password})
+ token = headers.get("Authorization")
+ if not token or not isinstance(profile, dict) or not profile.get("id"):
+ raise RuntimeError("SDK environment login did not return an identity and Authorization header")
+ api.session.headers["Authorization"] = token
+ key, _ = api.call("POST", "/system/tokens")
+ if not isinstance(key, dict) or not key.get("token"):
+ raise RuntimeError("SDK environment token creation did not return an API key")
+ return api, profile["id"], key["token"]
+ except Exception:
+ api.close()
+ raise
+
+
+def _models(api, credentials):
+ providers = (
+ ("ZHIPU-AI", credentials["ZHIPU_AI_API_KEY"], "chat", ("glm-4-flash", "glm-4-flashx")),
+ ("SILICONFLOW", credentials["SILICONFLOW_API_KEY"], "rerank", ("BAAI/bge-reranker-v2-m3",)),
+ )
+ for provider, key, kind, names in providers:
+ api.call("PUT", "/providers", {"provider_name": provider})
+ api.call(
+ "POST",
+ f"/providers/{provider}/instances",
+ {
+ "instance_name": "CI",
+ "api_key": key,
+ "base_url": "",
+ "region": "default",
+ "model_info": [{"model_type": [kind], "model_name": name, "max_tokens": 8192} for name in names],
+ },
+ )
+ for kind, identifier in (("chat", CHAT), ("embedding", EMBEDDING), ("rerank", RERANK)):
+ name, instance, provider = identifier.rsplit("@", 2)
+ api.call(
+ "PATCH",
+ "/models/default",
+ {
+ "model_provider": provider,
+ "model_instance": instance,
+ "model_type": kind,
+ "model_name": name,
+ },
+ )
+
+
+def _prepare_ci_environment(folder_name):
+ if os.getenv("RAGFLOW_SDK_CI") != "1" or os.getenv("CI") != "true" or not os.getenv("HOST_ADDRESS") or os.getenv("DOC_ENGINE") not in {"infinity", "elasticsearch"}:
+ raise RuntimeError("SDK provisioning requires explicit SDK CI opt-in, CI=true, HOST_ADDRESS and a supported DOC_ENGINE in a disposable stack")
+ credentials = {name: os.getenv(name) for name in ("ZHIPU_AI_API_KEY", "SILICONFLOW_API_KEY")}
+ missing = [name for name, value in credentials.items() if not value]
+ if missing:
+ raise RuntimeError("Full SDK integration tests require credentials: " + ", ".join(missing))
+ base_url = os.environ["HOST_ADDRESS"].rstrip("/")
+ engine = os.environ["DOC_ENGINE"]
+ api, tenant_id, api_key = _tenant(base_url)
+ try:
+ _models(api, credentials)
+ other, other_id, other_key = _tenant(base_url)
+ other.close()
+ env = {
+ "RAGFLOW_SDK_ISOLATED": "1",
+ "RAGFLOW_SDK_BASE_URL": base_url,
+ "RAGFLOW_SDK_API_KEY": api_key,
+ "RAGFLOW_SDK_TENANT_ID": tenant_id,
+ "RAGFLOW_SDK_OTHER_API_KEY": other_key,
+ "RAGFLOW_SDK_OTHER_TENANT_ID": other_id,
+ "RAGFLOW_SDK_DOC_ENGINE": engine,
+ "RAGFLOW_SDK_EMBEDDING_MODEL": EMBEDDING,
+ "RAGFLOW_SDK_MEMORY_EMBD_ID": EMBEDDING,
+ "RAGFLOW_SDK_MEMORY_LLM_ID": CHAT,
+ "RAGFLOW_SDK_MEMORY_UPDATE_LLM_ID": UPDATE_CHAT,
+ "RAGFLOW_SDK_RERANK_ID": RERANK,
+ "RAGFLOW_SDK_CHAT_CONFIGURED": "1",
+ }
+ if folder_name == "test_dataset_mangement":
+ template, _ = api.call("GET", "/pipelines/general")
+ pipeline, _ = api.call(
+ "POST",
+ "/agents",
+ {
+ "title": "SDK CI ingestion",
+ "canvas_category": "dataflow_canvas",
+ "dsl": template["dsl"],
+ },
+ )
+ version, _ = api.call("POST", f"/agents/{pipeline['id']}/publish", {})
+ env.update(RAGFLOW_SDK_PIPELINE_ID=pipeline["id"], RAGFLOW_SDK_PIPELINE_VERSION_ID=version["id"])
+ return env
+ finally:
+ api.close()
+
+
[email protected](scope="session", autouse=True)
+def set_tenant_info():
+ # Audited SDK fixtures own their tenant setup; never configure the shared QA account.
+ return None
+
+
[email protected](tryfirst=True)
+def pytest_runtest_setup(item):
+ if os.getenv("RAGFLOW_SDK_CI") != "1" or item.get_closest_marker("integration") is None or item.get_closest_marker("skip") is not None:
return
- for item in items:
- for test_path, reason in GO_ONLY_PATH_SKIPS.items():
- matched_at = item.nodeid.find(test_path)
- matched_suffix = item.nodeid[matched_at + len(test_path) :] if matched_at >= 0 else ""
- if matched_at >= 0 and (not matched_suffix or matched_suffix.startswith("[") or matched_suffix.startswith("::")):
- item.add_marker(pytest.mark.skip(reason=reason))
- break
+ # Run before folder-scoped session fixtures read their environment settings.
+ folder = item.path.parent.name
+ environments = item.config._sdk_ci_environments
+ if folder not in environments:
+ try:
+ environments[folder] = _prepare_ci_environment(folder)
+ except Exception as error:
+ detail = str(error) if isinstance(error, RuntimeError) else type(error).__name__
+ pytest.exit(f"SDK CI provisioning failed: {detail}", returncode=1)
+ for key, value in environments[folder].items():
+ item.config._sdk_ci_environment.setenv(key, value)
+
+
+def pytest_unconfigure(config):
+ config._sdk_ci_environment.undo()
@wait_for(200, 1, "Document parsing timeout")
diff --git a/test/testcases/test_sdk_api/test_agent_management/pytest.ini b/test/testcases/test_sdk_api/test_agent_management/pytest.ini
index 6ad4fab78f..414ce70e07 100644
--- a/test/testcases/test_sdk_api/test_agent_management/pytest.ini
+++ b/test/testcases/test_sdk_api/test_agent_management/pytest.ini
@@ -1,5 +1,5 @@
[pytest]
-pythonpath = ../../../../sdk/python
+pythonpath = ../../../.. ../../../../sdk/python
addopts = --strict-markers
markers =
integration: requires disposable Go backend and dedicated empty tenant
diff --git a/test/testcases/test_sdk_api/test_chat_assistant_management/README.md b/test/testcases/test_sdk_api/test_chat_assistant_management/README.md
deleted file mode 100644
index 43b34c9089..0000000000
--- a/test/testcases/test_sdk_api/test_chat_assistant_management/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Chat assistant SDK tests
-
-Run from the repository root with Python 3.13, the current `sdk/python` dependencies,
-pytest and Pillow installed. These tests deliberately exclude ancestor fixtures
-that provision models, require provider keys, or rewrite marker selection.
-Both `-c` and `--confcutdir` are required:
-
-```sh
-folder=test/testcases/test_sdk_api/test_chat_assistant_management
-python -m pytest -c "$folder/pytest.ini" --confcutdir="$folder" "$folder" --collect-only -q
-python -m pytest -c "$folder/pytest.ini" --confcutdir="$folder" "$folder" -m 'not integration' -q
-```
-
-Mocked tests need no backend or credentials and block unmocked network requests.
-Live tests fail setup unless all three environment variables are configured:
-
-- `RAGFLOW_SDK_ISOLATED=1`: confirms a dedicated disposable Go deployment and tenant.
-- `RAGFLOW_SDK_BASE_URL`: the deployment base URL.
-- `RAGFLOW_SDK_API_KEY`: the dedicated tenant owner's API key.
-
-Provision that environment independently; a reachable server does not establish
-isolation. Use an empty tenant without shared resources, with a configured default
-chat model, embedding model, document engine and storage. Dataset association tests
-upload documents and add manual chunks; they never start parsing or poll jobs.
-Run serially, without xdist or another client sharing the tenant. The initial
-preflight rejects accessible chats/datasets; delete-all cases additionally check
-the complete current chat IDs immediately before deletion.
-
-Run the live suite by replacing `-m 'not integration'` with `-m integration`.
-Cleanup deletes only IDs created by each test and reports cleanup errors. No model
-configuration or tenant-wide cleanup runs automatically. Targeted source-defect
-skips retain their expected assertions and need rechecking when their owning
-SDK or Go implementation changes; a skip is not a live reproduction.
diff --git a/test/testcases/test_sdk_api/test_chat_assistant_management/conftest.py b/test/testcases/test_sdk_api/test_chat_assistant_management/conftest.py
index 352084bcae..917f565caa 100644
--- a/test/testcases/test_sdk_api/test_chat_assistant_management/conftest.py
+++ b/test/testcases/test_sdk_api/test_chat_assistant_management/conftest.py
@@ -97,9 +97,9 @@ def client(isolated_tenant, monkeypatch):
errors.append(str(exc))
for dataset_id in datasets:
try:
- if rag.list_datasets(id=dataset_id):
+ if rag.list_datasets(ids=[dataset_id]):
rag.delete_datasets(ids=[dataset_id])
- assert rag.list_datasets(id=dataset_id) == [], f"Dataset cleanup failed: {dataset_id}"
+ assert rag.list_datasets(ids=[dataset_id]) == [], f"Dataset cleanup failed: {dataset_id}"
except Exception as exc: # noqa: BLE001 - SDK raises plain Exception; report every cleanup failure.
errors.append(str(exc))
assert not errors, "Owned resource cleanup failed: " + "; ".join(errors)
diff --git a/test/testcases/test_sdk_api/test_chat_assistant_management/pytest.ini b/test/testcases/test_sdk_api/test_chat_assistant_management/pytest.ini
index c545b1dc53..8994c41788 100644
--- a/test/testcases/test_sdk_api/test_chat_assistant_management/pytest.ini
+++ b/test/testcases/test_sdk_api/test_chat_assistant_management/pytest.ini
@@ -15,7 +15,7 @@
#
[pytest]
-pythonpath = ../../../../sdk/python
+pythonpath = ../../../.. ../../../../sdk/python
addopts = --strict-markers
markers =
integration: requires an explicitly isolated Go backend and dedicated empty tenant
diff --git a/test/testcases/test_sdk_api/test_chat_assistant_management/test_chat_crud_unit.py b/test/testcases/test_sdk_api/test_chat_assistant_management/test_chat_crud_unit.py
index a311fcc0d8..706d9a74f4 100644
--- a/test/testcases/test_sdk_api/test_chat_assistant_management/test_chat_crud_unit.py
+++ b/test/testcases/test_sdk_api/test_chat_assistant_management/test_chat_crud_unit.py
@@ -17,7 +17,7 @@
from copy import deepcopy
from inspect import unwrap
-import conftest as chat_fixtures
+from test.testcases.test_sdk_api.test_chat_assistant_management import conftest as chat_fixtures
import pytest
import requests
from beartype.roar import BeartypeCallHintParamViolation
@@ -215,8 +215,8 @@ def test_fixture_cleanup_only_deletes_owned_resources(monkeypatch):
def list_chats(self, id):
return [id] if id in chats else []
- def list_datasets(self, id):
- return [id] if id in datasets else []
+ def list_datasets(self, *, ids):
+ return [dataset_id for dataset_id in ids if dataset_id in datasets]
def delete_chats(self, ids):
deleted.extend(ids)
diff --git a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/README.md b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/README.md
deleted file mode 100644
index 0183cf0ad7..0000000000
--- a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/README.md
+++ /dev/null
@@ -1,170 +0,0 @@
-# Chunk SDK contract audit
-
-This folder targets the checked-in Python SDK and Go API. It does not use the
-legacy Python server as a contract oracle. No production code or full SDK CI is
-changed. Dataset/document audit PRs #21619 and #21633 are not prerequisites.
-
-## Running safely
-
-Run from the repository root with **both** the local config and `--confcutdir`.
-This excludes ancestor fixtures that bootstrap credentials, mutate configuration,
-parse shared documents, or delete every dataset belonging to the test tenant.
-
-```sh
-CHUNKS=test/testcases/test_sdk_api/test_chunk_management_within_dataset
-python -m pytest -c "$CHUNKS/pytest.ini" --confcutdir="$CHUNKS" "$CHUNKS" --collect-only -q
-python -m pytest -c "$CHUNKS/pytest.ini" --confcutdir="$CHUNKS" "$CHUNKS" -m 'not integration' -q
-```
-
-Integration requires a disposable **Go backend and dedicated tenant**, an embedding
-model configured for that tenant, and its search/storage dependencies. Set
-`RAGFLOW_SDK_ISOLATED=1`, `RAGFLOW_SDK_BASE_URL`, and `RAGFLOW_SDK_API_KEY` only after
-verifying ownership of that environment, then run the same command without `-m`.
-The guard fails setup rather than disguising missing infrastructure as a defect
-skip. `RAGFLOW_SDK_INDEX_TIMEOUT` controls the indexing deadline (default 60 seconds).
-Request connect/read timeouts are 5/60 seconds. API errors are never retried as
-indexing lag. The 1,000-chunk deletion case is intentionally substantial.
-
-The valid reranker case also requires `RAGFLOW_SDK_RERANK_ID`; keyword expansion
-requires a configured tenant chat model and `RAGFLOW_SDK_CHAT_CONFIGURED=1`.
-Missing model configuration fails the relevant case; it is not a production skip.
-Run against Elasticsearch and Infinity separately. Current `internal/engine/global.go`
-has no OpenSearch backend; obsolete OpenSearch count branches are removed.
-
-Fixtures create a unique dataset per case and delete only that dataset ID, including
-when upload fails. Cleanup errors remain visible and deletion is verified by ID.
-Chunks are created manually; there is no ingestion run or `document.run == "DONE"`
-assumption. Listing and retrieval readiness are checked independently. Raw list
-responses are used for persistence probes because the SDK list schema is defective;
-a separate skipped test retains the correct public SDK schema assertions.
-
-## Contract evidence
-
-The audited call paths are:
-
-- `sdk/python/ragflow_sdk/modules/document.py`: `add_chunk`, `delete_chunks`,
- `list_chunks`; `modules/chunk.py`: `Chunk.update`, `ChunkUpdateError`;
- `ragflow.py`: `RAGFlow.retrieve`.
-- `internal/handler/chunk.go`: request binding, query validation, update type
- handling; `internal/service/chunk/chunk.go`: add/list/update/remove semantics,
- ownership, image storage, engine requests and response fields.
-- `internal/handler/dataset.go`: `SearchDatasets` typed request validation;
- `internal/service/dataset/search.go` and `internal/service/nlp/`: retrieval,
- candidate selection, score ordering, document/metadata/availability filtering.
-- `internal/engine/elasticsearch/chunk.go`, `internal/engine/infinity/chunk.go`:
- lexical/vector matching and fusion. `top_k` is a candidate limit, not a promised
- response count; `page_size` is a response limit.
-- `docs/references/python_api_reference.md` and `http_api_reference.md`: chunk and
- retrieval contracts. Python-specific exception examples are obsolete. The old
- empty-question example also conflicts with current Go required-field validation.
-- `internal/handler/chunk_test.go`, `internal/service/chunk/chunk_test.go`,
- `internal/handler/dataset_search_test.go`, and `test/api/retrieval_api_test.go`:
- existing Go validation, ownership, idempotency, schema and retrieval coverage.
-
-These sources establish: add rejects empty/non-string content and invalid list
-payloads; update accepts empty string content but must reject invalid types;
-questions are trimmed and empty entries removed; duplicate adds use a stable ID;
-delete is document-scoped and unknown/repeated IDs are idempotent; numeric list
-query strings are accepted, whereas retrieval JSON numeric strings are rejected.
-Updates return `None` and do not mutate the SDK object's cached attributes.
-
-Retrieval tests use a small owned corpus with a shared lexical query, threshold
-zero and text-only readiness checks. They assert identity, ownership, content,
-finite ordered scores, pagination, filtering and response limits. They do not
-require arbitrary four/five-result counts from normal hybrid retrieval. The
-single-result lexical list filters use unique terms in the owned fixture.
-
-## Original test inventory and decisions
-
-All six original files, their fixtures/helpers, and every parameter branch were
-reviewed: **36 original test methods, 134 collected parameter cases**. Classification
-below is by original method: **20 UPDATE, 16 REPLACE, 0 unchanged KEEP, 0 whole-test
-DELETE**. Valid checks within rewritten methods remain. Consolidated duplicates
-include engine-specific lexical/top-k alternatives and repeated missing-argument
-checks; missing-argument behavior now has a service-free test. SKIP is an orthogonal
-case-level outcome, detailed below, rather than deletion of the original assertions.
-
-| Original file / method | Original cases | Decision | Coverage after audit |
-| --- | ---: | --- | --- |
-| add / content | 6 | UPDATE | Null, empty, whitespace, integer, text and punctuation; failed requests do not add IDs. |
-| add / important_keywords | 6 | UPDATE | String lists, empty members, duplicates, non-string members and scalar rejection. |
-| add / questions | 6 | UPDATE | Same boundaries plus normalization of blank questions. |
-| add / tag_kwd | 6 | UPDATE | String-list contract and exact Go validation messages. |
-| add / repeated_add_chunk | 1 | UPDATE | Same content returns the same ID and persists once. |
-| add / add_chunk_to_deleted_document | 1 | UPDATE | Current document ownership error. |
-| add / concurrent_add_chunk | 1 | UPDATE | Consume all 50 futures, unique IDs and persisted ID set. |
-| delete / delete_partial_invalid_id | 3 | REPLACE | Unknown IDs at three positions do not prevent owned valid deletions. |
-| delete / repeated_deletion | 1 | REPLACE | Repeated deletion is idempotent. |
-| delete / duplicate_deletion | 1 | REPLACE | Duplicate IDs are idempotent. |
-| delete / concurrent_deletion | 1 | UPDATE | All futures succeed and persistence becomes empty. |
-| delete / delete_1k | 1 | UPDATE | Preserve bulk coverage; paginated readiness and deletion probes. |
-| delete / basic_scenarios | 6 | REPLACE | Unknown/single/all IDs, explicit delete_all, safe no-op and Python kwargs boundary. |
-| list / page | 7 | UPDATE | Default/null, valid pages, numeric strings, zero/negative/non-numeric validation. |
-| list / page_size | 7 | UPDATE | Default/null, bounds, numeric strings and invalid values. |
-| list / keywords | 7 | REPLACE | Empty/default, shared term, unique term, numeric term and no-match; no engine count exceptions. |
-| list / id | 4 | REPLACE | Empty IDs remain active; known/unknown filters retain correct expectations under targeted skips. |
-| list / concurrent_list | 1 | UPDATE | Consume each future and validate owned fixture count. |
-| list / default | 1 | UPDATE | 31 explicit chunks establish the default limit of 30; no sleep. |
-| list / invalid_document_id_raises | 1 | UPDATE | Assert meaningful current Go error text. |
-| retrieval / basic_scenarios | 4 | REPLACE | Owned results with/without document filter; Python argument errors tested separately. |
-| retrieval / page | 7 | REPLACE | Compare slices of a controlled baseline; retain invalid inputs in shared negative matrix. |
-| retrieval / page_size | 5 | REPLACE | Defaults, single result, caps and typed/range errors. |
-| retrieval / vector_similarity_weight | 4 | UPDATE | Weights 0, 0.5, 1; finite ordered owned results and invalid ranges/types. |
-| retrieval / top_k | 5 | REPLACE | Candidate limits 1/10/2048, response cap; invalid values, no engine result-count branches. |
-| retrieval / rerank_id | 2 | REPLACE | Configured reranker and explicit unknown-model rejection; no blanket skip. |
-| retrieval / keyword | 5 | REPLACE | False/null/true, configured expansion, string-bool rejection; no blanket skip. |
-| retrieval / concurrent_retrieval | 1 | UPDATE | Consume all futures and verify nonempty owned ordered results. |
-| update / content | 6 | UPDATE | Persist text/punctuation/empty/space; null/integer rejection remains skipped for defect. |
-| update / important_keywords | 6 | REPLACE | Shared typed list matrix; seed then clear; invalid cases retain rejection assertions. |
-| update / questions | 6 | REPLACE | Shared matrix with trimming/blank normalization and invalid-type skips. |
-| update / tag_kwd | 6 | REPLACE | Shared matrix with active strict negative cases. |
-| update / available | 6 | REPLACE | Both bool transitions persist; string/integer rejection retained under defect skip. |
-| update / repeated_update_chunk | 1 | UPDATE | Every sequential/repeated write is verified in storage. |
-| update / concurrent_update_chunk | 1 | UPDATE | 50 contending writes across four chunks; all futures observed and final values submitted. |
-| update / update_chunk_to_deleted_document | 1 | UPDATE | `ChunkUpdateError`, current code/message rather than generic exception. |
-
-New coverage includes add list-null/empty and image payload boundaries; delete_all
-conflict/document isolation; list response schema; retrieval negative matrix,
-document/metadata/availability filters and pagination uniqueness; unsupported update
-fields; SDK payload/default/error contracts; polling and cleanup failure behavior.
-
-## Skip audit
-
-Historical references were inspected rather than carried forward based on issue
-status: #6411, #6509, #6499, #6554 and #10692 concern the legacy Python backend;
-PR #6376 addressed duplicate-ID deletion validation. Their old skips are removed
-or replaced by the current defects below. The old `**"not json"` case never reaches
-HTTP; a service-free TypeError check replaces that skip. Old list negative-input
-skips now assert Go validation, and rerank/keyword groups execute with explicit
-model prerequisites. No retrieval group is blanket-skipped.
-
-**20 cases remain skipped for source-confirmed contract defects:**
-
-| Cases | Defect and source boundary | Correct assertion retained |
-| ---: | --- | --- |
-| 3 | `RemoveChunks` rejects omitted/null/empty IDs without delete_all, contrary to both API references. | Safe no-op preserves IDs. |
-| 2 | SDK `list_chunks(id=...)` sends `id`; Go `ListChunks` reads `chunk_ids`. | Known ID selects one; unknown ID returns none. |
-| 1 | Go list returns storage names (`chunk_id`, `content_with_weight`, `important_kwd`, `question_kwd`) and omits document/dataset IDs; SDK constructs `Chunk` without mapping. | SDK identity/content/ownership/keyword/question schema. |
-| 2 | Go `UpdateChunk` silently ignores null/integer content. | Typed `ChunkUpdateError` mentioning content. |
-| 4 | Go update ignores invalid keyword scalar/null types or converts non-string members to empty strings. | List-type validation error. |
-| 4 | Go update has the same invalid questions handling. | List-type validation error. |
-| 4 | Go update silently ignores string/integer availability. | Typed `ChunkUpdateError` mentioning availability. |
-
-No production fix is included. Defects are confirmed by current source paths, not
-by integration execution in this audit environment. Correct assertions remain
-inside every skipped case.
-
-## Validation boundary
-
-The resulting suite collects **195 cases**: add 39, delete 17, list 28, retrieval
-48, update 40, and 23 service-free SDK/fixture cases. Python syntax and focused
-Ruff checks pass. All **23 service-free cases pass**, including payloads, SDK error
-propagation, cleanup ownership/failures, deadlines and pagination-loop detection.
-
-A full invocation with no isolated backend configured produces **23 passed,
-20 skipped, 152 setup errors, zero assertion failures**. Every setup error is the
-explicit integration isolation guard; report these as **152 environment-blocked
-cases**, not production defects or successful integration tests. The existing
-host stack is not verified disposable and was not used. Elasticsearch/Infinity,
-model-backed retrieval/reranking/keyword expansion, 1,000-chunk deletion, images
-and concurrency still require execution in the isolated environment described above.
diff --git a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/conftest.py b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/conftest.py
index 940e99a693..83fddd7ae6 100644
--- a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/conftest.py
+++ b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/conftest.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -95,7 +95,7 @@ def add_document(client):
yield dataset, documents[0]
finally:
client.delete_datasets(ids=[dataset.id])
- assert client.list_datasets(id=dataset.id) == [], "Owned dataset cleanup failed"
+ assert client.list_datasets(ids=[dataset.id]) == [], "Owned dataset cleanup failed"
@pytest.fixture
diff --git a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/pytest.ini b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/pytest.ini
index 4434268134..6c9e67569b 100644
--- a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/pytest.ini
+++ b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/pytest.ini
@@ -1,5 +1,5 @@
[pytest]
-pythonpath = ../../../../sdk/python
+pythonpath = ../../../.. ../../../../sdk/python
addopts = --strict-markers
markers =
integration: requires an explicitly isolated Go backend and dedicated tenant
diff --git a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_add_chunk.py b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_add_chunk.py
index 8cc923204e..11e6a4f930 100644
--- a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_add_chunk.py
+++ b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_add_chunk.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
# limitations under the License.
#
from concurrent.futures import ThreadPoolExecutor, as_completed
-from conftest import raw_ids, wait_ids
+from test.testcases.test_sdk_api.test_chunk_management_within_dataset.conftest import raw_ids, wait_ids
import pytest
from ragflow_sdk import Chunk
@@ -40,9 +40,7 @@ class TestAddChunk:
@pytest.mark.parametrize(
"payload, expected_message",
[
- ({"content": None}, "`content` is required"),
({"content": ""}, "`content` is required"),
- ({"content": 1}, "`content` must be a string"),
({"content": "a"}, ""),
({"content": " "}, "`content` is required"),
({"content": "\n!?。;!?\"'"}, ""),
@@ -69,10 +67,7 @@ class TestAddChunk:
[
({"content": "chunk test important_keywords 1", "important_keywords": ["a", "b", "c"]}, ""),
({"content": "chunk test important_keywords 2", "important_keywords": [""]}, ""),
- ({"content": "chunk test important_keywords 3", "important_keywords": [1]}, "`important_keywords` must be a list of strings"),
({"content": "chunk test important_keywords 4", "important_keywords": ["a", "a"]}, ""),
- ({"content": "chunk test important_keywords 5", "important_keywords": "abc"}, "`important_keywords` is required to be a list"),
- ({"content": "chunk test important_keywords 6", "important_keywords": 123}, "`important_keywords` is required to be a list"),
],
)
def test_important_keywords(self, add_document, payload, expected_message):
@@ -96,10 +91,7 @@ class TestAddChunk:
[
({"content": "chunk test test_questions 1", "questions": ["a", "b", "c"]}, ""),
({"content": "chunk test test_questions 2", "questions": [""]}, ""),
- ({"content": "chunk test test_questions 3", "questions": [1]}, "`questions` must be a list of strings"),
({"content": "chunk test test_questions 4", "questions": ["a", "a"]}, ""),
- ({"content": "chunk test test_questions 5", "questions": "abc"}, "`questions` is required to be a list"),
- ({"content": "chunk test test_questions 6", "questions": 123}, "`questions` is required to be a list"),
],
)
def test_questions(self, add_document, payload, expected_message):
@@ -123,10 +115,7 @@ class TestAddChunk:
[
({"content": "chunk test test_tag_kwd 1", "tag_kwd": ["tag1", "tag2"]}, ""),
({"content": "chunk test test_tag_kwd 2", "tag_kwd": [""]}, ""),
- ({"content": "chunk test test_tag_kwd 3", "tag_kwd": [1]}, "`tag_kwd` must be a list of strings"),
({"content": "chunk test test_tag_kwd 4", "tag_kwd": ["tag", "tag"]}, ""),
- ({"content": "chunk test test_tag_kwd 5", "tag_kwd": "abc"}, "`tag_kwd` is required to be a list"),
- ({"content": "chunk test test_tag_kwd 6", "tag_kwd": 123}, "`tag_kwd` is required to be a list"),
],
)
def test_tag_kwd(self, add_document, payload, expected_message):
diff --git a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_chunk_sdk_contract.py b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_chunk_sdk_contract.py
index 500c352e94..07180b54ce 100644
--- a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_chunk_sdk_contract.py
+++ b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_chunk_sdk_contract.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,7 +16,8 @@
from unittest.mock import Mock
import pytest
-from conftest import add_document, raw_ids, wait_until
+from beartype.roar import BeartypeCallHintParamViolation
+from test.testcases.test_sdk_api.test_chunk_management_within_dataset.conftest import add_document, raw_ids, wait_until
from ragflow_sdk import Chunk, Document, RAGFlow
from ragflow_sdk.modules.chunk import ChunkUpdateError
@@ -173,7 +174,7 @@ def test_wait_deadline():
def test_pagination_detects_repeated_pages(document, monkeypatch):
- monkeypatch.setattr("conftest.raw_chunks", lambda *args, **kwargs: [{"chunk_id": str(i)} for i in range(100)])
+ monkeypatch.setattr("test.testcases.test_sdk_api.test_chunk_management_within_dataset.conftest.raw_chunks", lambda *args, **kwargs: [{"chunk_id": str(i)} for i in range(100)])
with pytest.raises(AssertionError, match="pagination repeated IDs"):
raw_ids(document)
@@ -194,7 +195,7 @@ def test_fixture_cleanup_is_owned_and_errors_visible(delete_fails):
else:
with pytest.raises(StopIteration):
next(fixture)
- client.list_datasets.assert_called_once_with(id="owned-dataset")
+ client.list_datasets.assert_called_once_with(ids=["owned-dataset"])
client.delete_datasets.assert_called_once_with(ids=["owned-dataset"])
@@ -206,3 +207,29 @@ def test_fixture_cleans_up_after_upload_error():
with pytest.raises(RuntimeError, match="upload failure"):
next(add_document.__wrapped__(client))
client.delete_datasets.assert_called_once_with(ids=["owned-dataset"])
+
+
+ "field,value",
+ [("content", None), ("content", 1)] + [(field, value) for field in ("important_keywords", "questions", "tag_kwd") for value in ([1], "abc", 123)],
+)
+def test_add_chunk_rejects_invalid_types_before_http(sdk, document, monkeypatch, field, value):
+ post = Mock()
+ monkeypatch.setattr(sdk, "post", post)
+ with pytest.raises(BeartypeCallHintParamViolation, match=f"parameter {field}="):
+ document.add_chunk(**{"content": "text", field: value})
+ post.assert_not_called()
+
+
+def test_fixture_cleanup_detects_surviving_dataset():
+ client = Mock()
+ dataset = client.create_dataset.return_value
+ dataset.id = "owned-dataset"
+ dataset.upload_documents.return_value = [Mock(id="owned-document")]
+ client.list_datasets.return_value = [dataset]
+ fixture = add_document.__wrapped__(client)
+ next(fixture)
+ with pytest.raises(AssertionError, match="Owned dataset cleanup failed"):
+ next(fixture)
+ client.delete_datasets.assert_called_once_with(ids=["owned-dataset"])
diff --git a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_delete_chunks.py b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_delete_chunks.py
index 9b1c1d076a..93be5d59c0 100644
--- a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_delete_chunks.py
+++ b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_delete_chunks.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
from concurrent.futures import ThreadPoolExecutor, as_completed
import pytest
-from conftest import raw_ids, wait_ids
+from test.testcases.test_sdk_api.test_chunk_management_within_dataset.conftest import raw_ids, wait_ids
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_list_chunks.py b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_list_chunks.py
index eed021b58a..a412537a01 100644
--- a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_list_chunks.py
+++ b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_list_chunks.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
from concurrent.futures import ThreadPoolExecutor, as_completed
import pytest
-from conftest import wait_ids
+from test.testcases.test_sdk_api.test_chunk_management_within_dataset.conftest import wait_ids
from ragflow_sdk import Document
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_retrieval_chunks.py b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_retrieval_chunks.py
index 9df55cb0f6..61897bc3f6 100644
--- a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_retrieval_chunks.py
+++ b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_retrieval_chunks.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import os
from concurrent.futures import ThreadPoolExecutor, as_completed
import pytest
-from conftest import raw_chunks, wait_until
+from test.testcases.test_sdk_api.test_chunk_management_within_dataset.conftest import raw_chunks, wait_until
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_update_chunk.py b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_update_chunk.py
index 053530fc12..b1b78e1abc 100644
--- a/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_update_chunk.py
+++ b/test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_update_chunk.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
from concurrent.futures import ThreadPoolExecutor, as_completed
import pytest
-from conftest import raw_chunks, wait_until
+from test.testcases.test_sdk_api.test_chunk_management_within_dataset.conftest import raw_chunks, wait_until
from ragflow_sdk.modules.chunk import ChunkUpdateError
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_dataset_mangement/README.md b/test/testcases/test_sdk_api/test_dataset_mangement/README.md
deleted file mode 100644
index 9d0e4a71d5..0000000000
--- a/test/testcases/test_sdk_api/test_dataset_mangement/README.md
+++ /dev/null
@@ -1,68 +0,0 @@
-<!--
-Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-# Dataset SDK tests
-
-Run from the repository root with Python 3.13 and the current SDK installed:
-
-```sh
-uv venv --python 3.13 /tmp/ragflow-sdk-tests
-uv pip install --python /tmp/ragflow-sdk-tests/bin/python -e sdk/python pytest
-/tmp/ragflow-sdk-tests/bin/python -m pytest test/testcases/test_sdk_api/test_dataset_mangement --collect-only
-/tmp/ragflow-sdk-tests/bin/python -m pytest test/testcases/test_sdk_api/test_dataset_mangement -m 'not integration'
-```
-
-The folder's `pytest.ini` keeps collection and mocked contracts independent of the
-legacy parent conftests, provider keys, backend setup, and priority filtering.
-For an explicit configuration path, use `-c test/testcases/test_sdk_api/test_dataset_mangement/pytest.ini`.
-Do not collect this folder together with unaudited SDK folders under the old parent configuration.
-
-Integration tests require a dedicated **Go** test deployment and an initially empty
-test tenant. Do not use a shared deployment or production credentials. Provision
-services and a default embedding model before running; the fixtures do not register
-users, configure providers, or change tenant defaults. Run serially, without xdist.
-
-Set these environment variables:
-
-- `RAGFLOW_SDK_ISOLATED=1`: confirms the deployment and tenant are dedicated to this run.
-- `RAGFLOW_SDK_BASE_URL`: the Go HTTP API base URL.
-- `RAGFLOW_SDK_API_KEY`: an owner API key for the empty test tenant.
-- `RAGFLOW_SDK_EMBEDDING_MODEL`: an accessible canonical `model@instance@provider` identifier for explicit model tests.
-- `RAGFLOW_SDK_PIPELINE_ID` and `RAGFLOW_SDK_PIPELINE_VERSION_ID`: an accessible ingestion pipeline and its published version for parser-mode update tests.
-- `RAGFLOW_SDK_DOC_ENGINE`: the configured document engine for pagerank capability tests.
-- `RAGFLOW_SDK_OTHER_API_KEY`: a valid key belonging to an unrelated test tenant for resource permission tests.
-
-```sh
-/tmp/ragflow-sdk-tests/bin/python -m pytest test/testcases/test_sdk_api/test_dataset_mangement -m 'integration and not p3'
-# Includes 1,000-dataset capacity and concurrent request scenarios:
-/tmp/ragflow-sdk-tests/bin/python -m pytest test/testcases/test_sdk_api/test_dataset_mangement -m integration
-```
-
-Missing environment requirements fail setup with a prerequisite message; they are
-not product-defect skips. Cleanup only deletes IDs returned by this test's creates,
-including successful creates before a later failure, and preserves unrelated IDs.
-No live test or fixture calls `delete_all=True`; its payload is checked with mocks.
-
-Four explicit skips preserve supported expectations blocked by confirmed source defects:
-
-- Create and update accept 128 BMP characters, but Go counts UTF-8 bytes in
- `internal/service/dataset/crud.go` and `update.go`.
-- Pipeline creation is documented in the SDK, but `RAGFlow.create_dataset` cannot
- send `pipeline_version_id`, which Go requires (`empty_version_test.go`).
-- Negative pagerank should report the lower bound; `update.go` reports the upper
- bound for both range violations.
-
-The suite does not enable CI execution or change production implementations.
diff --git a/test/testcases/test_sdk_api/test_dataset_mangement/pytest.ini b/test/testcases/test_sdk_api/test_dataset_mangement/pytest.ini
index c545b1dc53..8994c41788 100644
--- a/test/testcases/test_sdk_api/test_dataset_mangement/pytest.ini
+++ b/test/testcases/test_sdk_api/test_dataset_mangement/pytest.ini
@@ -15,7 +15,7 @@
#
[pytest]
-pythonpath = ../../../../sdk/python
+pythonpath = ../../../.. ../../../../sdk/python
addopts = --strict-markers
markers =
integration: requires an explicitly isolated Go backend and dedicated empty tenant
diff --git a/test/testcases/test_sdk_api/test_dataset_mangement/test_infrastructure.py b/test/testcases/test_sdk_api/test_dataset_mangement/test_infrastructure.py
index 62e585d0f4..8fa0fb4e3c 100644
--- a/test/testcases/test_sdk_api/test_dataset_mangement/test_infrastructure.py
+++ b/test/testcases/test_sdk_api/test_dataset_mangement/test_infrastructure.py
@@ -18,7 +18,7 @@
from types import SimpleNamespace
-import conftest as fixtures
+from test.testcases.test_sdk_api.test_dataset_mangement import conftest as fixtures
import pytest
@@ -80,3 +80,146 @@ def test_cleanup_only_deletes_created_survivors_after_failure(monkeypatch):
next(fixture)
assert deleted == ["survivor"]
assert set(datasets) == {"unrelated"}
+
+
+def sdk_fixtures(monkeypatch):
+ # Standalone contract runs do not load the ancestor's credential configuration.
+ for key in ("ZHIPU_AI_API_KEY", "SILICONFLOW_API_KEY"):
+ if not fixtures.os.getenv(key):
+ monkeypatch.setenv(key, "test-only")
+ from test.testcases.test_sdk_api import conftest
+
+ return conftest
+
+
[email protected]("engine", ["infinity", "elasticsearch"])
+def test_ci_provisions_owned_tenants_models_and_pipeline(monkeypatch, sdk_fixtures, engine):
+
+ for key, value in {
+ "RAGFLOW_SDK_CI": "1",
+ "CI": "true",
+ "HOST_ADDRESS": "http://example.invalid",
+ "DOC_ENGINE": engine,
+ "ZHIPU_AI_API_KEY": "test-chat-key",
+ "SILICONFLOW_API_KEY": "test-rerank-key",
+ }.items():
+ monkeypatch.setenv(key, value)
+ calls = []
+ accounts = []
+ sessions = []
+
+ class Session:
+ def __init__(self):
+ self.headers = {}
+ self.closed = False
+ sessions.append(self)
+
+ def request(self, method, url, *, json, timeout):
+ assert timeout == 120
+ path = url.removeprefix("http://example.invalid/api/v1")
+ calls.append((method, path, json))
+ data, headers = None, {}
+ if path == "/users":
+ accounts.append(json["email"])
+ self.identity = str(len(accounts))
+ elif path == "/auth/login":
+ data, headers = {"id": self.identity}, {"Authorization": f"jwt-{self.identity}"}
+ elif path == "/system/tokens":
+ assert self.headers["Authorization"] == f"jwt-{self.identity}"
+ data = {"token": f"key-{self.identity}"}
+ elif path == "/pipelines/general":
+ data = {"dsl": {"components": {}}}
+ elif path == "/agents":
+ data = {"id": "pipeline"}
+ elif path == "/agents/pipeline/publish":
+ data = {"id": "version"}
+ return SimpleNamespace(status_code=200, headers=headers, json=lambda: {"code": 0, "data": data})
+
+ def close(self):
+ self.closed = True
+
+ monkeypatch.setattr(sdk_fixtures.requests, "Session", Session)
+ env = sdk_fixtures._prepare_ci_environment("test_dataset_mangement")
+ assert len(set(accounts)) == 2
+ assert all(email.startswith("sdk-") for email in accounts)
+ assert env["RAGFLOW_SDK_ISOLATED"] == "1"
+ assert env["RAGFLOW_SDK_API_KEY"] == "key-1"
+ assert env["RAGFLOW_SDK_OTHER_API_KEY"] == "key-2"
+ assert env["RAGFLOW_SDK_TENANT_ID"] != env["RAGFLOW_SDK_OTHER_TENANT_ID"]
+ assert env["RAGFLOW_SDK_DOC_ENGINE"] == engine
+ assert env["RAGFLOW_SDK_PIPELINE_ID"] == "pipeline"
+ assert env["RAGFLOW_SDK_PIPELINE_VERSION_ID"] == "version"
+ assert env["RAGFLOW_SDK_MEMORY_LLM_ID"] != env["RAGFLOW_SDK_MEMORY_UPDATE_LLM_ID"]
+ assert [body["model_type"] for method, path, body in calls if path == "/models/default"] == ["chat", "embedding", "rerank"]
+ assert all(session.closed for session in sessions)
+ assert not any(method == "DELETE" for method, _, _ in calls)
+
+
[email protected]("missing", ["RAGFLOW_SDK_CI", "HOST_ADDRESS", "DOC_ENGINE", "ZHIPU_AI_API_KEY", "SILICONFLOW_API_KEY"])
+def test_ci_setup_rejects_missing_prerequisites_before_network(monkeypatch, sdk_fixtures, missing):
+
+ for key, value in {"RAGFLOW_SDK_CI": "1", "CI": "true", "HOST_ADDRESS": "http://example.invalid", "DOC_ENGINE": "infinity", "ZHIPU_AI_API_KEY": "test", "SILICONFLOW_API_KEY": "test"}.items():
+ monkeypatch.setenv(key, value)
+ monkeypatch.delenv(missing)
+ monkeypatch.setattr(sdk_fixtures.requests, "Session", lambda: pytest.fail("Invalid CI setup must not open a connection"))
+ with pytest.raises(RuntimeError, match="requires|require credentials"):
+ sdk_fixtures._prepare_ci_environment("test_dataset_mangement")
+
+
+def test_ci_hook_reuses_folder_accounts_and_leaves_contract_tests_offline(monkeypatch, sdk_fixtures):
+ from pathlib import Path
+
+ monkeypatch.setenv("RAGFLOW_SDK_CI", "1")
+ prepared = []
+
+ def prepare(folder):
+ prepared.append(folder)
+ return {"RAGFLOW_SDK_API_KEY": folder}
+
+ monkeypatch.setattr(sdk_fixtures, "_prepare_ci_environment", prepare)
+ config = SimpleNamespace(_sdk_ci_environments={}, _sdk_ci_environment=monkeypatch)
+ item = SimpleNamespace(path=Path("test_dataset_mangement/test_example.py"), config=config, get_closest_marker=lambda name: object() if name == "integration" else None)
+ sdk_fixtures.pytest_runtest_setup(item)
+ monkeypatch.setenv("RAGFLOW_SDK_API_KEY", "other-folder")
+ sdk_fixtures.pytest_runtest_setup(item)
+ assert prepared == ["test_dataset_mangement"]
+ assert sdk_fixtures.os.environ["RAGFLOW_SDK_API_KEY"] == "test_dataset_mangement"
+ item.path = Path("test_agent_management/test_example.py")
+ sdk_fixtures.pytest_runtest_setup(item)
+ assert prepared == ["test_dataset_mangement", "test_agent_management"]
+ item.get_closest_marker = lambda name: None
+ sdk_fixtures.pytest_runtest_setup(item)
+ assert len(prepared) == 2
+
+
[email protected]("http_status,code", [(500, 0), (200, 102)])
+def test_ci_setup_propagates_errors_without_response_secrets(monkeypatch, sdk_fixtures, http_status, code):
+
+ session = SimpleNamespace(request=lambda *args, **kwargs: SimpleNamespace(status_code=http_status, headers={}, json=lambda: {"code": code, "message": "secret-provider-key"}))
+ monkeypatch.setattr(sdk_fixtures.requests, "Session", lambda: session)
+ with pytest.raises(RuntimeError, match="SDK environment setup failed") as error:
+ sdk_fixtures._API("http://example.invalid").call("POST", "/providers/example/instances", {"api_key": "secret-provider-key"})
+ assert "secret-provider-key" not in str(error.value)
+
+
+def test_ci_hook_stops_run_after_bootstrap_failure(monkeypatch, sdk_fixtures):
+ from pathlib import Path
+
+ monkeypatch.setenv("RAGFLOW_SDK_CI", "1")
+
+ def fail_setup(folder):
+ raise RuntimeError("SDK environment setup failed: POST /providers/example/instances")
+
+ monkeypatch.setattr(sdk_fixtures, "_prepare_ci_environment", fail_setup)
+ config = SimpleNamespace(_sdk_ci_environments={}, _sdk_ci_environment=monkeypatch)
+ item = SimpleNamespace(path=Path("test_dataset_mangement/test_example.py"), config=config, get_closest_marker=lambda name: object() if name == "integration" else None)
+ with pytest.raises(pytest.exit.Exception, match="SDK environment setup failed") as error:
+ sdk_fixtures.pytest_runtest_setup(item)
+ assert error.value.returncode == 1
+ assert config._sdk_ci_environments == {}
diff --git a/test/testcases/test_sdk_api/test_file_management_within_dataset/README.md b/test/testcases/test_sdk_api/test_file_management_within_dataset/README.md
deleted file mode 100644
index 93f53807a9..0000000000
--- a/test/testcases/test_sdk_api/test_file_management_within_dataset/README.md
+++ /dev/null
@@ -1,66 +0,0 @@
-<!--
-
- Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-
-# Document SDK tests
-
-This folder targets the current Python SDK and Go backend only. Its local pytest
-configuration prevents inherited legacy backend fixtures and marker filters from
-loading; it does not depend on the open dataset-audit PR or change other suites.
-Run it serially from the repository root, without selecting a parent pytest
-configuration or combining it with unaudited SDK folders.
-
-## Service-free contracts
-
-Install the SDK and its existing test dependencies into a Python 3.13 environment:
-
-```sh
-uv venv --python 3.13 /tmp/ragflow-sdk-document-tests
-uv pip install --python /tmp/ragflow-sdk-document-tests/bin/python -e sdk/python --group sdk/python/pyproject.toml:test
-/tmp/ragflow-sdk-document-tests/bin/python -m pytest test/testcases/test_sdk_api/test_file_management_within_dataset -m 'not integration'
-/tmp/ragflow-sdk-document-tests/bin/python -m pytest test/testcases/test_sdk_api/test_file_management_within_dataset --collect-only -q
-```
-
-Unmarked contract tests cannot open network connections. Fixtures, payload mapping,
-error propagation, download bytes and polling behavior are testable without Go,
-credentials, model setup or external storage.
-
-## Isolated Go integrations
-
-Provide a disposable Go deployment and a dedicated **empty** test tenant. The API,
-database, object store and configured search engine must work; parsing also needs
-the ingestor, queue and the tenant's configured embedding model/provider. Do not
-point these tests at a shared tenant or assume a running local service is isolated.
-
-```sh
-export RAGFLOW_SDK_ISOLATED=1
-export RAGFLOW_SDK_BASE_URL=http://isolated-go-host:9380
-export RAGFLOW_SDK_API_KEY=dedicated-test-tenant-key
-/tmp/ragflow-sdk-document-tests/bin/python -m pytest test/testcases/test_sdk_api/test_file_management_within_dataset -m integration
-```
-
-Missing prerequisites fail setup rather than being mislabeled as product skips.
-Before mutations, a read-only probe rejects a nonempty tenant. Each test creates
-fresh datasets, and teardown deletes only tracked dataset IDs, including their
-owned documents; no shared cleanup helper or tenant-wide deletion is used. HTTP
-calls have connect/read timeouts; parsing waits have explicit deadlines.
-
-`RAGFLOW_SDK_PARSE_TIMEOUT` optionally changes the parsing deadline (180 seconds by
-default). A timeout or unavailable model/service is an environment/test failure,
-not automatic evidence of a product defect. Targeted skips document independently
-confirmed implementation defects in the affected tests. Python SDK CI execution
-remains disabled; this PR does not change workflows or production code.
diff --git a/test/testcases/test_sdk_api/test_file_management_within_dataset/pytest.ini b/test/testcases/test_sdk_api/test_file_management_within_dataset/pytest.ini
index 0354b66c6d..5efc1b3847 100644
--- a/test/testcases/test_sdk_api/test_file_management_within_dataset/pytest.ini
+++ b/test/testcases/test_sdk_api/test_file_management_within_dataset/pytest.ini
@@ -15,7 +15,7 @@
#
[pytest]
-pythonpath = ../../../../sdk/python ../..
+pythonpath = ../../../.. ../../../../sdk/python ../..
addopts = --strict-markers
markers =
integration: requires an explicitly isolated Go backend and dedicated empty tenant
diff --git a/test/testcases/test_sdk_api/test_file_management_within_dataset/test_infrastructure.py b/test/testcases/test_sdk_api/test_file_management_within_dataset/test_infrastructure.py
index dc7f47b428..a7db9769b6 100644
--- a/test/testcases/test_sdk_api/test_file_management_within_dataset/test_infrastructure.py
+++ b/test/testcases/test_sdk_api/test_file_management_within_dataset/test_infrastructure.py
@@ -18,7 +18,7 @@
from types import SimpleNamespace
-import conftest as fixtures
+from test.testcases.test_sdk_api.test_file_management_within_dataset import conftest as fixtures
import pytest
diff --git a/test/testcases/test_sdk_api/test_file_management_within_dataset/test_update_document.py b/test/testcases/test_sdk_api/test_file_management_within_dataset/test_update_document.py
index eab263dd4f..fe9be941c5 100644
--- a/test/testcases/test_sdk_api/test_file_management_within_dataset/test_update_document.py
+++ b/test/testcases/test_sdk_api/test_file_management_within_dataset/test_update_document.py
@@ -14,26 +14,34 @@
# limitations under the License.
#
+import os
from unittest.mock import Mock
import pytest
from ragflow_sdk import Document
+_unindexed_rename = pytest.mark.skipif(
+ os.getenv("RAGFLOW_SDK_DOC_ENGINE", os.getenv("DOC_ENGINE")) == "elasticsearch",
+ reason="Go updateDocumentNameOnly updates chunks for an unparsed document without an Elasticsearch index (document_dataset_update.go:587; elasticsearch/chunk.go:353)",
+)
+
+
@pytest.mark.integration
class TestDocumentsUpdated:
@pytest.mark.p1
@pytest.mark.parametrize(
"name, expected_message",
[
- ("new_name.txt", ""),
- (f"{'a' * 251}.txt", ""),
+ pytest.param("new_name.txt", "", marks=_unindexed_rename),
+ pytest.param(f"{'a' * 251}.txt", "", marks=_unindexed_rename),
(0, "Field: <name> - Message: <Input should be a valid string> - Value: <0>"),
(None, "Field: <name> - Message: <Input should be a valid string> - Value: <None>"),
("", "the extension of file can't be changed"),
("ragflow_test_upload_0", "the extension of file can't be changed"),
("ragflow_test_upload_1.txt", "duplicated document name in the same dataset"),
- ("RAGFLOW_TEST_UPLOAD_1.TXT", ""),
+ ("RAGFLOW_TEST_UPLOAD_1.TXT", "duplicated document name in the same dataset"),
+ pytest.param("RAGFLOW_TEST_UPLOAD_0.TXT", "", marks=_unindexed_rename),
],
)
def test_name(self, add_documents, name, expected_message):
@@ -107,8 +115,8 @@ class TestDocumentParserSelection:
("presentation", "selected pipeline does not support file type"),
("picture", "selected pipeline does not support file type"),
("email", "selected pipeline does not support file type"),
- ("knowledge_graph", "selected pipeline does not support file type"),
- ("tag", "selected pipeline does not support file type"),
+ ("knowledge_graph", "unknown builtin parser_id: knowledge_graph"),
+ ("tag", "unknown builtin parser_id: tag"),
("", "`chunk_method` (empty string) is not valid"),
("other_chunk_method", "unknown builtin parser_id: other_chunk_method"),
],
diff --git a/test/testcases/test_sdk_api/test_memory_management/pytest.ini b/test/testcases/test_sdk_api/test_memory_management/pytest.ini
index 69d69e7f1a..2bb06a2124 100644
--- a/test/testcases/test_sdk_api/test_memory_management/pytest.ini
+++ b/test/testcases/test_sdk_api/test_memory_management/pytest.ini
@@ -14,7 +14,7 @@
# limitations under the License.
#
[pytest]
-pythonpath = ../../../../sdk/python
+pythonpath = ../../../.. ../../../../sdk/python
addopts = --strict-markers
markers =
integration: requires a verified isolated Go backend and dedicated empty tenant
diff --git a/test/testcases/test_sdk_api/test_memory_management/test_memory_fixtures.py b/test/testcases/test_sdk_api/test_memory_management/test_memory_fixtures.py
index 45a95e77bf..0cbbd58dd5 100644
--- a/test/testcases/test_sdk_api/test_memory_management/test_memory_fixtures.py
+++ b/test/testcases/test_sdk_api/test_memory_management/test_memory_fixtures.py
@@ -18,7 +18,7 @@ from types import SimpleNamespace
import pytest
-import conftest
+from test.testcases.test_sdk_api.test_memory_management import conftest
def fake_client(monkeypatch, *, fail_cleanup=False):
diff --git a/test/testcases/test_sdk_api/test_message_management/conftest.py b/test/testcases/test_sdk_api/test_message_management/conftest.py
index 5e5197be2d..5017932b1f 100644
--- a/test/testcases/test_sdk_api/test_message_management/conftest.py
+++ b/test/testcases/test_sdk_api/test_message_management/conftest.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import pytest
import requests
from ragflow_sdk import RAGFlow
-from message_helpers import assert_identity, wait_until
+from test.testcases.test_sdk_api.test_message_management.message_helpers import assert_identity, wait_until
@pytest.fixture(autouse=True)
diff --git a/test/testcases/test_sdk_api/test_message_management/pytest.ini b/test/testcases/test_sdk_api/test_message_management/pytest.ini
index 9a17a5e963..aba1601c4a 100644
--- a/test/testcases/test_sdk_api/test_message_management/pytest.ini
+++ b/test/testcases/test_sdk_api/test_message_management/pytest.ini
@@ -1,5 +1,5 @@
[pytest]
-pythonpath = ../../../../sdk/python .
+pythonpath = ../../../.. ../../../../sdk/python .
addopts = --strict-markers
markers =
integration: requires a verified disposable Go backend and dedicated empty tenant
diff --git a/test/testcases/test_sdk_api/test_message_management/test_add_message.py b/test/testcases/test_sdk_api/test_message_management/test_add_message.py
index 18909ffbed..e17d5526b6 100644
--- a/test/testcases/test_sdk_api/test_message_management/test_add_message.py
+++ b/test/testcases/test_sdk_api/test_message_management/test_add_message.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ from uuid import uuid4
import pytest
from ragflow_sdk import RAGFlow
-from message_helpers import assert_content, assert_identity, wait_until
+from test.testcases.test_sdk_api.test_message_management.message_helpers import assert_content, assert_identity, wait_until
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_message_management/test_forget_message.py b/test/testcases/test_sdk_api/test_message_management/test_forget_message.py
index b6f23ebcfe..85b3ce6f29 100644
--- a/test/testcases/test_sdk_api/test_message_management/test_forget_message.py
+++ b/test/testcases/test_sdk_api/test_message_management/test_forget_message.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
import pytest
from ragflow_sdk import Memory, RAGFlow
-from message_helpers import assert_content, wait_until
+from test.testcases.test_sdk_api.test_message_management.message_helpers import assert_content, wait_until
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_message_management/test_get_message_content.py b/test/testcases/test_sdk_api/test_message_management/test_get_message_content.py
index 4cf01b6a11..8a9b00af6b 100644
--- a/test/testcases/test_sdk_api/test_message_management/test_get_message_content.py
+++ b/test/testcases/test_sdk_api/test_message_management/test_get_message_content.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ import math
import pytest
from ragflow_sdk import Memory, RAGFlow
-from message_helpers import assert_content
+from test.testcases.test_sdk_api.test_message_management.message_helpers import assert_content
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_message_management/test_get_recent_message.py b/test/testcases/test_sdk_api/test_message_management/test_get_recent_message.py
index a3f58a8cd4..01a50a5247 100644
--- a/test/testcases/test_sdk_api/test_message_management/test_get_recent_message.py
+++ b/test/testcases/test_sdk_api/test_message_management/test_get_recent_message.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
import pytest
from ragflow_sdk import RAGFlow
-from message_helpers import assert_identity, wait_until
+from test.testcases.test_sdk_api.test_message_management.message_helpers import assert_identity, wait_until
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_message_management/test_list_message.py b/test/testcases/test_sdk_api/test_message_management/test_list_message.py
index 7ee36d4d4f..99f11b2d48 100644
--- a/test/testcases/test_sdk_api/test_message_management/test_list_message.py
+++ b/test/testcases/test_sdk_api/test_message_management/test_list_message.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
import pytest
from ragflow_sdk import Memory, RAGFlow
-from message_helpers import assert_identity
+from test.testcases.test_sdk_api.test_message_management.message_helpers import assert_identity
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_message_management/test_message_authorization.py b/test/testcases/test_sdk_api/test_message_management/test_message_authorization.py
index aef286a112..d431e66020 100644
--- a/test/testcases/test_sdk_api/test_message_management/test_message_authorization.py
+++ b/test/testcases/test_sdk_api/test_message_management/test_message_authorization.py
@@ -1,3 +1,19 @@
+#
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
"""Cross-tenant access uses a second unprivileged API key, never another tenant's data."""
import os
@@ -5,7 +21,7 @@ import os
import pytest
from ragflow_sdk import Memory, RAGFlow
-from message_helpers import assert_content
+from test.testcases.test_sdk_api.test_message_management.message_helpers import assert_content
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_message_management/test_message_fixtures.py b/test/testcases/test_sdk_api/test_message_management/test_message_fixtures.py
index db16067b9b..625f9cc762 100644
--- a/test/testcases/test_sdk_api/test_message_management/test_message_fixtures.py
+++ b/test/testcases/test_sdk_api/test_message_management/test_message_fixtures.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@ from types import SimpleNamespace
import pytest
-import conftest
-import message_helpers
+from test.testcases.test_sdk_api.test_message_management import conftest
+from test.testcases.test_sdk_api.test_message_management import message_helpers
def lifecycle(monkeypatch, *, failing_id=None, wrong_tenant=False):
diff --git a/test/testcases/test_sdk_api/test_message_management/test_search_message.py b/test/testcases/test_sdk_api/test_message_management/test_search_message.py
index 2263fb5746..da6bed53b4 100644
--- a/test/testcases/test_sdk_api/test_message_management/test_search_message.py
+++ b/test/testcases/test_sdk_api/test_message_management/test_search_message.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
import pytest
from ragflow_sdk import RAGFlow
-from message_helpers import assert_identity, wait_until
+from test.testcases.test_sdk_api.test_message_management.message_helpers import assert_identity, wait_until
def assert_matches(messages, populated, indices):
diff --git a/test/testcases/test_sdk_api/test_message_management/test_update_message_status.py b/test/testcases/test_sdk_api/test_message_management/test_update_message_status.py
index 2850540f63..f0ff5b8b2d 100644
--- a/test/testcases/test_sdk_api/test_message_management/test_update_message_status.py
+++ b/test/testcases/test_sdk_api/test_message_management/test_update_message_status.py
@@ -1,5 +1,5 @@
#
-# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
+# Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
import pytest
from ragflow_sdk import Memory, RAGFlow
-from message_helpers import assert_content, wait_until
+from test.testcases.test_sdk_api.test_message_management.message_helpers import assert_content, wait_until
pytestmark = pytest.mark.integration
diff --git a/test/testcases/test_sdk_api/test_session_management/pytest.ini b/test/testcases/test_sdk_api/test_session_management/pytest.ini
index de540b5360..6297e2620d 100644
--- a/test/testcases/test_sdk_api/test_session_management/pytest.ini
+++ b/test/testcases/test_sdk_api/test_session_management/pytest.ini
@@ -1,5 +1,5 @@
[pytest]
-pythonpath = ../../../../sdk/python
+pythonpath = ../../../.. ../../../../sdk/python
addopts = --strict-markers
markers =
integration: requires disposable Go backend and dedicated empty tenant