fix(avatar): align knowledge upload limit with production
This commit is contained in:
@@ -64,6 +64,29 @@ def test_upload_returns_before_background_vectorization(
|
||||
db.close()
|
||||
|
||||
|
||||
def test_upload_rejects_oversize_file_before_queuing_indexing(
|
||||
tmp_path: Path,
|
||||
authorization_context,
|
||||
):
|
||||
context = authorization_context
|
||||
with (
|
||||
patch("routers.knowledge.UPLOAD_DIR", str(tmp_path)),
|
||||
patch("routers.knowledge.MAX_UPLOAD_BYTES", 4),
|
||||
patch("routers.knowledge.knowledge_vectorizer.enqueue") as enqueue,
|
||||
):
|
||||
response = client.post(
|
||||
f"/api/avatar/{context['avatar'].id}/knowledge/docs",
|
||||
headers=context["owner_headers"],
|
||||
files={"file": ("oversize.md", b"12345", "text/markdown")},
|
||||
)
|
||||
|
||||
payload = response.json()
|
||||
assert payload["code"] == 400
|
||||
assert payload["message"] == "文件不能超过 100MB"
|
||||
enqueue.assert_not_called()
|
||||
assert not list((tmp_path / context["avatar"].id).glob("*"))
|
||||
|
||||
|
||||
def test_background_vectorizer_commits_ready_document_and_chunks_together(
|
||||
tmp_path: Path,
|
||||
authorization_context,
|
||||
|
||||
Reference in New Issue
Block a user