Skip to content

latent.testing

Testing utilities for Latent framework.

Functions

assert_input_dataset_exists

assert_input_dataset_exists(flow_name: str, dataset_name: str)

Assert that an input dataset file exists on filesystem.

Args: flow_name: Name of the flow dataset_name: Name of the dataset

Raises: AssertionError: If dataset doesn't exist

create_test_dataframe

create_test_dataframe(rows: int = 10, columns: list[str] | None = None) -> pd.DataFrame

Create a test DataFrame with sample data.

Args: rows: Number of rows columns: List of column names (default: ["col1", "col2", "col3"])

Returns: DataFrame with sample data

mock_catalog

mock_catalog(datasets: dict[str, Any])

Mock catalog for testing flows without real data dependencies.

This context manager replaces the catalog loading mechanism with in-memory data, allowing you to test flows without file I/O or actual data files.

Args: datasets: Dictionary mapping dataset names to data objects

Example: >>> with mock_catalog({"raw_data": pd.DataFrame([{"x": 1}])}): ... my_flow() # Runs with mocked data

mock_config

mock_config(config: dict[str, Any])

Mock configuration for testing flows.

Args: config: Dictionary of configuration parameters

Example: >>> with mock_config({"batch_size": 10}): ... my_flow() # Runs with mocked config

Attributes

SUPPORTED_EXTENSIONS