Test: Update test cases for PR #6405 #6504 #6538 (#6565)

### What problem does this PR solve?

PR #6405 #6504 #6538

### Type of change

- [x] update test cases
This commit is contained in:
liu an 2025-03-26 19:23:13 +08:00 committed by GitHub
parent b7d7ad536a
commit 6599db1e99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 8 deletions

View File

@ -28,7 +28,7 @@ def validate_chunk_details(dataset_id, document_id, payload, res):
if "important_keywords" in payload:
assert chunk["important_keywords"] == payload["important_keywords"]
if "questions" in payload:
assert chunk["questions"] == payload["questions"]
assert chunk["questions"] == [str(q).strip() for q in payload.get("questions", []) if str(q).strip()]
class TestAuthorization:
@ -119,12 +119,7 @@ class TestAddChunk:
"payload, expected_code, expected_message",
[
({"content": "chunk test", "questions": ["a", "b", "c"]}, 0, ""),
pytest.param(
{"content": "chunk test", "questions": [""]},
0,
"",
marks=pytest.mark.skip(reason="issues/6404"),
),
({"content": "chunk test", "questions": [""]}, 0, ""),
({"content": "chunk test", "questions": [1]}, 100, "TypeError('sequence item 0: expected str instance, int found')"),
({"content": "chunk test", "questions": ["a", "a"]}, 0, ""),
({"content": "chunk test", "questions": "abc"}, 102, "`questions` is required to be a list"),
@ -138,6 +133,7 @@ class TestAddChunk:
assert False, res
chunks_count = res["data"]["doc"]["chunk_count"]
res = add_chunk(get_http_api_auth, dataset_id, document_id, payload)
print(res)
assert res["code"] == expected_code
if expected_code == 0:
validate_chunk_details(dataset_id, document_id, payload, res)

View File

@ -109,7 +109,7 @@ class TestChunksList:
[
(None, 0, 5, ""),
("", 0, 5, ""),
pytest.param(lambda r: r[0], 0, 1, "", marks=pytest.mark.skip(reason="issues/6499")),
pytest.param(lambda r: r[0], 0, 1, "", marks=pytest.mark.skipif(os.getenv("DOC_ENGINE") == "infinity", reason="issues/6499")),
pytest.param("unknown", 100, 0, """AttributeError("\'NoneType\' object has no attribute \'keys\'")""", marks=pytest.mark.skip),
],
)