conftest.py

Overview

The conftest.py file is a pytest configuration module that defines reusable fixtures for use in testing the InfiniFlow system, specifically focusing on dataset management via the RAGFlow client API. It provides setup and teardown logic to create and clean up datasets required by various test classes and functions. This allows tests to run with a consistent dataset environment while ensuring no residual data affects subsequent tests.


Detailed Components

Imports


Fixtures

add_datasets

@pytest.fixture(scope="class")
def add_datasets(request: FixtureRequest, client: RAGFlow, WebApiAuth: RAGFlowWebApiAuth) -> list[str]:
class TestDatasetOperations:
    def test_dataset_count(self, add_datasets):
        assert len(add_datasets) == 5

add_datasets_func

@pytest.fixture(scope="function")
def add_datasets_func(request: FixtureRequest, client: RAGFlow, WebApiAuth: RAGFlowWebApiAuth) -> list[str]:
def test_modify_dataset(add_datasets_func):
    dataset_ids = add_datasets_func
    # perform operations on the 3 datasets

Important Implementation Details


Interaction with Other System Parts


Visual Diagram

flowchart TD
    A[add_datasets (class scope)] -->|calls| B[batch_create_datasets(WebApiAuth, 5)]
    A -->|registers finalizer| C[cleanup -> client.delete_datasets(ids=None)]

    D[add_datasets_func (function scope)] -->|calls| E[batch_create_datasets(WebApiAuth, 3)]
    D -->|registers finalizer| F[cleanup -> client.delete_datasets(ids=None)]

    B --> G[RAGFlowWebApiAuth]
    E --> G

    C --> H[RAGFlow client]
    F --> H

Summary

conftest.py is a pytest configuration file focused on managing dataset lifecycle for testing the InfiniFlow RAGFlow system. By providing fixtures that create and clean up datasets at different granularities (class vs. function), it simplifies test setup and teardown, enabling reliable and isolated test runs. This file is a crucial part of the test infrastructure, facilitating integration and functional testing of dataset-related features.


End of Documentation for conftest.py