您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. import pytest
  17. from common import delete_dataset
  18. from libs.utils.file_utils import (
  19. create_docx_file,
  20. create_eml_file,
  21. create_excel_file,
  22. create_html_file,
  23. create_image_file,
  24. create_json_file,
  25. create_md_file,
  26. create_pdf_file,
  27. create_ppt_file,
  28. create_txt_file,
  29. )
  30. @pytest.fixture(scope="function")
  31. def clear_datasets(get_http_api_auth):
  32. yield
  33. delete_dataset(get_http_api_auth)
  34. @pytest.fixture
  35. def generate_test_files(request, tmp_path):
  36. file_creators = {
  37. "docx": (tmp_path / "ragflow_test.docx", create_docx_file),
  38. "excel": (tmp_path / "ragflow_test.xlsx", create_excel_file),
  39. "ppt": (tmp_path / "ragflow_test.pptx", create_ppt_file),
  40. "image": (tmp_path / "ragflow_test.png", create_image_file),
  41. "pdf": (tmp_path / "ragflow_test.pdf", create_pdf_file),
  42. "txt": (tmp_path / "ragflow_test.txt", create_txt_file),
  43. "md": (tmp_path / "ragflow_test.md", create_md_file),
  44. "json": (tmp_path / "ragflow_test.json", create_json_file),
  45. "eml": (tmp_path / "ragflow_test.eml", create_eml_file),
  46. "html": (tmp_path / "ragflow_test.html", create_html_file),
  47. }
  48. files = {}
  49. for file_type, (file_path, creator_func) in file_creators.items():
  50. if request.param in ["", file_type]:
  51. creator_func(file_path)
  52. files[file_type] = file_path
  53. return files