Fix file link-to-datasets to suport both replace and add (#817) (#16908)

This commit is contained in:
Wang Qi
2026-07-14 20:12:31 +08:00
committed by GitHub
parent 376a9057a8
commit 55d5879622
6 changed files with 157 additions and 18 deletions

View File

@@ -59,6 +59,10 @@ def _set_request_json(monkeypatch, module, payload_state):
monkeypatch.setattr(module, "get_request_json", _req_json)
def _set_request_args(monkeypatch, module, args):
monkeypatch.setattr(module, "request", SimpleNamespace(args=args))
@pytest.fixture(scope="session")
def auth():
return "unit-auth"
@@ -119,6 +123,10 @@ def _load_file2document_module(monkeypatch):
def delete_by_file_id(*_args, **_kwargs):
return None
@staticmethod
def delete_by_document_id(*_args, **_kwargs):
return None
@staticmethod
def insert(_payload):
return SimpleNamespace(to_json=lambda: {})
@@ -242,6 +250,7 @@ def test_convert_branch_matrix_unit(monkeypatch):
module = _load_file2document_module(monkeypatch)
req_state = {"kb_ids": ["kb-1"], "file_ids": ["f1"]}
_set_request_json(monkeypatch, module, req_state)
_set_request_args(monkeypatch, module, {})
# Falsy file returns "File not found!" during synchronous validation.
monkeypatch.setattr(module.FileService, "get_by_ids", lambda _ids: [_FalsyFile("f1", module.FileType.DOC.value)])