選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

conftest.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. from time import sleep
  17. import pytest
  18. from common import batch_add_chunks, delete_chunks, list_chunks, list_documents, parse_documents
  19. from utils import wait_for
  20. @wait_for(30, 1, "Document parsing timeout")
  21. def condition(_auth, _kb_id):
  22. res = list_documents(_auth, {"kb_id": _kb_id})
  23. for doc in res["data"]["docs"]:
  24. if doc["run"] != "3":
  25. return False
  26. return True
  27. @pytest.fixture(scope="function")
  28. def add_chunks_func(request, WebApiAuth, add_document):
  29. def cleanup():
  30. res = list_chunks(WebApiAuth, {"doc_id": document_id})
  31. chunk_ids = [chunk["chunk_id"] for chunk in res["data"]["chunks"]]
  32. delete_chunks(WebApiAuth, {"doc_id": document_id, "chunk_ids": chunk_ids})
  33. request.addfinalizer(cleanup)
  34. kb_id, document_id = add_document
  35. parse_documents(WebApiAuth, {"doc_ids": [document_id], "run": "1"})
  36. condition(WebApiAuth, kb_id)
  37. chunk_ids = batch_add_chunks(WebApiAuth, document_id, 4)
  38. # issues/6487
  39. sleep(1)
  40. return kb_id, document_id, chunk_ids