RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
tests: add missing HTTP API tests for dataset management endpoints removed in #14222 (#14390)
euvred78013964af8
diff --git a/test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py b/test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.pyindex f74f7855ba..8dcb58c313 100644--- a/test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py+++ b/test/testcases/test_http_api/test_dataset_management/test_ingestion_logs.py@@ -51,3 +51,21 @@ class TestGetIngestionLog:def test_get_ingestion_log_invalid_dataset(self, HttpApiAuth):res = get_ingestion_log(HttpApiAuth, "invalid_id", "some_log_id")assert res["code"] != 0, res++[email protected]("clear_datasets")+class TestListIngestionLogsEdgeCases:+ @pytest.mark.p3+ def test_list_ingestion_logs_abnormal_date_filter(self, HttpApiAuth, add_dataset_func):+ """Test list ingestion logs when create_date_from > create_date_to."""+ dataset_id = add_dataset_func+ res = list_ingestion_logs(+ HttpApiAuth,+ dataset_id,+ params={+ "desc": "false",+ "create_date_from": "2025-02-01",+ "create_date_to": "2025-01-01",+ },+ )+ assert res["code"] != 0, resdiff --git a/test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_config.py b/test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_config.pynew file mode 100644index 0000000000..549340a470--- /dev/null+++ b/test/testcases/test_http_api/test_file_management_within_dataset/test_metadata_config.py@@ -0,0 +1,140 @@+#+# Copyright 2025 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.+#+import pytest+import requests+from configs import HOST_ADDRESS, VERSION, INVALID_API_TOKEN+from libs.auth import RAGFlowHttpApiAuth+from common import HEADERS++DATASETS_API_URL = f"/api/{VERSION}/datasets"+++def get_dataset_metadata_config(auth, dataset_id, *, headers=HEADERS):+ url = f"{HOST_ADDRESS}{DATASETS_API_URL}/{dataset_id}/metadata/config"+ res = requests.get(url=url, headers=headers, auth=auth)+ return res.json()+++def update_dataset_metadata_config(auth, dataset_id, payload=None, *, headers=HEADERS):+ url = f"{HOST_ADDRESS}{DATASETS_API_URL}/{dataset_id}/metadata/config"+ res = requests.put(url=url, headers=headers, auth=auth, json=payload)+ return res.json()+++def update_document_metadata_config(auth, dataset_id, document_id, payload=None, *, headers=HEADERS):+ url = f"{HOST_ADDRESS}{DATASETS_API_URL}/{dataset_id}/documents/{document_id}/metadata/config"+ res = requests.put(url=url, headers=headers, auth=auth, json=payload)+ return res.json()+++class TestDatasetMetadataConfigAuthorization:+ @pytest.mark.parametrize(+ "invalid_auth, expected_code, expected_message",+ [+ (None, 401, "<Unauthorized '401: Unauthorized'>"),+ (+ RAGFlowHttpApiAuth(INVALID_API_TOKEN),+ 401,+ "<Unauthorized '401: Unauthorized'>",+ ),+ ],+ )+ def test_get_metadata_config_auth_invalid(self, invalid_auth, expected_code, expected_message):+ res = get_dataset_metadata_config(invalid_auth, "dataset_id")+ assert res["code"] == expected_code, res+ assert res["message"] == expected_message, res++ @pytest.mark.parametrize(+ "invalid_auth, expected_code, expected_message",+ [+ (None, 401, "<Unauthorized '401: Unauthorized'>"),+ (+ RAGFlowHttpApiAuth(INVALID_API_TOKEN),+ 401,+ "<Unauthorized '401: Unauthorized'>",+ ),+ ],+ )+ def test_update_metadata_config_auth_invalid(self, invalid_auth, expected_code, expected_message):+ res = update_dataset_metadata_config(invalid_auth, "dataset_id", {})+ assert res["code"] == expected_code, res+ assert res["message"] == expected_message, res++[email protected]("clear_datasets")+class TestDatasetMetadataConfig:+ @pytest.mark.p2+ def test_get_metadata_config_success(self, HttpApiAuth, add_dataset_func):+ dataset_id = add_dataset_func+ res = get_dataset_metadata_config(HttpApiAuth, dataset_id)+ assert res["code"] == 0, res++ @pytest.mark.p2+ def test_get_metadata_config_invalid_dataset(self, HttpApiAuth):+ res = get_dataset_metadata_config(HttpApiAuth, "invalid_dataset_id")+ assert res["code"] != 0, res++ @pytest.mark.p2+ def test_update_metadata_config_missing_payload(self, HttpApiAuth, add_dataset_func):+ dataset_id = add_dataset_func+ res = update_dataset_metadata_config(HttpApiAuth, dataset_id)+ assert res["code"] != 0, res++ @pytest.mark.p2+ def test_update_metadata_config_invalid_dataset(self, HttpApiAuth):+ res = update_dataset_metadata_config(HttpApiAuth, "invalid_dataset_id", {"fields": []})+ assert res["code"] != 0, res+++class TestDocumentMetadataConfigAuthorization:+ @pytest.mark.parametrize(+ "invalid_auth, expected_code, expected_message",+ [+ (None, 401, "<Unauthorized '401: Unauthorized'>"),+ (+ RAGFlowHttpApiAuth(INVALID_API_TOKEN),+ 401,+ "<Unauthorized '401: Unauthorized'>",+ ),+ ],+ )+ def test_update_document_metadata_config_auth_invalid(self, invalid_auth, expected_code, expected_message):+ res = update_document_metadata_config(invalid_auth, "dataset_id", "document_id", {})+ assert res["code"] == expected_code, res+ assert res["message"] == expected_message, res++[email protected]("clear_datasets")+class TestDocumentMetadataConfig:+ @pytest.mark.p2+ def test_update_document_metadata_config_not_found(self, HttpApiAuth, add_dataset_func):+ dataset_id = add_dataset_func+ res = update_document_metadata_config(HttpApiAuth, dataset_id, "nonexistent_doc_id", {})+ assert res["code"] != 0, res++ @pytest.mark.p2+ def test_update_document_metadata_config_invalid_dataset(self, HttpApiAuth, add_document_func):+ _, doc_id = add_document_func+ res = update_document_metadata_config(HttpApiAuth, "invalid_dataset_id", doc_id, {})+ assert res["code"] != 0, res++ @pytest.mark.p2+ def test_update_document_metadata_config_invalid_document(self, HttpApiAuth, add_dataset_func):+ dataset_id = add_dataset_func+ res = update_document_metadata_config(HttpApiAuth, dataset_id, "invalid_doc_id", {})+ assert res["code"] != 0, res