conftest.py

Overview

The conftest.py file is a configuration module for pytest, providing reusable test fixtures that set up and tear down test data related to document management within the InfiniFlow testing environment. Specifically, it facilitates the creation and cleanup of datasets and documents through API calls, ensuring isolated and consistent test states across function- and class-scoped tests.

The fixtures in this file automate the lifecycle of knowledge base documents—uploading a specified number of documents before tests run and deleting them afterward to maintain a clean environment. This helps in testing workflows that involve document ingestion, retrieval, and deletion in a controlled manner.


Fixtures

1. add_document_func


2. add_documents


3. add_documents_func


Important Implementation Details


Interaction with Other Parts of the System


Visual Diagram

flowchart TD
    A[add_document_func (function scope)] -->|uses| B[add_dataset]
    A -->|calls| C[bulk_upload_documents (count=1)]
    A -->|calls| D[list_documents]
    A -->|calls| E[delete_document]

    F[add_documents (class scope)] -->|uses| B
    F -->|calls| C[bulk_upload_documents (count=5)]
    F -->|calls| D
    F -->|calls| E

    G[add_documents_func (function scope)] -->|uses| H[add_dataset_func]
    G -->|calls| C[bulk_upload_documents (count=3)]
    G -->|calls| D
    G -->|calls| E

    B -->|creates| I[Dataset]
    H -->|creates| I

    C -->|uploads docs to| I
    D -->|lists docs from| I
    E -->|deletes docs from| I

Summary

conftest.py defines pytest fixtures that automate the setup and teardown of document datasets used in testing. It ensures that documents are uploaded before tests and removed afterward, providing a clean slate for each test run. The fixtures vary by scope and number of documents uploaded, relying on external dataset creation fixtures and utility functions for API interactions. This modular setup streamlines testing workflows involving document ingestion and management within the InfiniFlow testing framework.