Testing Guide

This document describes the testing strategy used in ufs_plot_utils.

Testing Philosophy

The testing suite emphasizes:

  • isolated unit tests

  • lightweight smoke tests

  • minimal external dependencies

  • synthetic datasets

  • reproducible behavior

Test Layout

Example structure:

tests/
├── conftest.py
├── unit/
└── integration/

Shared Fixtures

tests/conftest.py provides reusable fixtures.

Common fixtures:

  • sample_da_tile

  • sample_da_grid

  • zero_da

Unit Tests

Config Tests

Verify:

  • YAML parsing

  • nested access

  • missing-key handling

DataReader Tests

Verify:

  • slicing behavior

  • tiled datasets

  • forecast detection

  • restart detection

  • observation handling

GeoReader Tests

Verify:

  • file-based geo loading

  • tiled geometry handling

  • MOM6/CICE coordinate mapping

  • observation lon/lat detection

Utility Tests

Verify:

  • tile dimension normalization

  • filename normalization

  • staggered-grid mapping

Pipeline Smoke Tests

Smoke tests validate end-to-end execution.

Typical workflow:

  1. Generate temporary YAML config

  2. Mock xarray readers

  3. Build pipeline

  4. Execute plotting tasks

  5. Verify successful completion

Running Tests

Run the full suite:

pytest

Run a subset:

pytest tests/unit

Run with verbose logging:

pytest -v

Future Improvements

Potential enhancements:

  • coverage enforcement

  • benchmark tests

  • image regression tests

  • Dask integration tests

  • cloud-storage mocking