mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-23 17:06:42 +08:00
Add Go service/handler tests for API contract parity (#16905)
This commit is contained in:
@@ -150,9 +150,7 @@ def _load_list_datasets_module(monkeypatch, *, kbs, parsing_status_by_kb):
|
||||
monkeypatch,
|
||||
"api.db.services.user_service",
|
||||
TenantService=SimpleNamespace(
|
||||
get_joined_tenants_by_user_id=lambda user_id: [
|
||||
{"tenant_id": "tenant-1"}
|
||||
],
|
||||
get_joined_tenants_by_user_id=lambda user_id: [{"tenant_id": "tenant-1"}],
|
||||
),
|
||||
UserService=SimpleNamespace(get_by_ids=lambda ids: []),
|
||||
UserTenantService=SimpleNamespace(),
|
||||
@@ -173,13 +171,9 @@ def _load_list_datasets_module(monkeypatch, *, kbs, parsing_status_by_kb):
|
||||
|
||||
repo_root = Path(__file__).resolve().parents[5]
|
||||
module_path = repo_root / "api" / "apps" / "services" / "dataset_api_service.py"
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"test_dataset_api_service_list_datasets_module", module_path
|
||||
)
|
||||
spec = importlib.util.spec_from_file_location("test_dataset_api_service_list_datasets_module", module_path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
monkeypatch.setitem(
|
||||
sys.modules, "test_dataset_api_service_list_datasets_module", module
|
||||
)
|
||||
monkeypatch.setitem(sys.modules, "test_dataset_api_service_list_datasets_module", module)
|
||||
spec.loader.exec_module(module)
|
||||
return module, parsing_status_mock, get_list_mock
|
||||
|
||||
@@ -343,4 +337,4 @@ def test_list_datasets_with_include_parsing_status_missing_kb_gets_empty_dict(mo
|
||||
by_id = {r["id"]: r for r in payload["data"]}
|
||||
assert by_id["kb-a"]["parsing_status"]["unstart_count"] == 1
|
||||
assert by_id["kb-b"]["parsing_status"] == {}
|
||||
parsing_status_mock.assert_called_once()
|
||||
parsing_status_mock.assert_called_once()
|
||||
|
||||
@@ -83,15 +83,9 @@ def test_chunk_shape_helper_recognises_chunk_payloads(monkeypatch):
|
||||
"""A response that is chunk-shaped (list, or dict with non-empty results/chunks)
|
||||
is classified as chunked regardless of which payload was sent."""
|
||||
module = _load_docling_parser(monkeypatch)
|
||||
assert module.DoclingParser._looks_like_chunk_response(
|
||||
[{"text": "chunk-1"}]
|
||||
) is True
|
||||
assert module.DoclingParser._looks_like_chunk_response(
|
||||
{"results": [{"text": "chunk-1"}, {"text": "chunk-2"}]}
|
||||
) is True
|
||||
assert module.DoclingParser._looks_like_chunk_response(
|
||||
{"chunks": [{"text": "chunk-1"}]}
|
||||
) is True
|
||||
assert module.DoclingParser._looks_like_chunk_response([{"text": "chunk-1"}]) is True
|
||||
assert module.DoclingParser._looks_like_chunk_response({"results": [{"text": "chunk-1"}, {"text": "chunk-2"}]}) is True
|
||||
assert module.DoclingParser._looks_like_chunk_response({"chunks": [{"text": "chunk-1"}]}) is True
|
||||
|
||||
|
||||
@pytest.mark.p2
|
||||
@@ -164,4 +158,4 @@ def test_remote_chunked_request_with_ignored_flag_does_not_log_success(monkeypat
|
||||
assert sections == [("real content", "")]
|
||||
flat = " ".join(record.getMessage() for record in caplog.records)
|
||||
assert "Successfully used native chunking" not in flat
|
||||
assert "Server ignored chunking request" in flat
|
||||
assert "Server ignored chunking request" in flat
|
||||
|
||||
Reference in New Issue
Block a user