from __future__ import annotations


def test_resolve_non_manifest_preflight_source_or_summary_returns_summary_early() -> None:
    from pyimgano.workbench.non_manifest_preflight_flow import (
        resolve_non_manifest_preflight_source_or_summary,
    )

    source = {"summary": {"status": "error"}}

    resolved = resolve_non_manifest_preflight_source_or_summary(source)

    assert resolved == {"status": "error"}


def test_resolve_non_manifest_preflight_source_or_summary_returns_none_when_no_summary() -> None:
    from pyimgano.workbench.non_manifest_preflight_flow import (
        resolve_non_manifest_preflight_source_or_summary,
    )

    source = {"summary": None, "dataset": "custom", "root": "/tmp/root"}

    resolved = resolve_non_manifest_preflight_source_or_summary(source)

    assert resolved is None


def test_resolve_non_manifest_category_listing_summary_returns_summary_early() -> None:
    from pyimgano.workbench.non_manifest_preflight_flow import (
        resolve_non_manifest_category_listing_summary,
    )

    listing = {"summary": {"status": "error"}}

    resolved = resolve_non_manifest_category_listing_summary(listing)

    assert resolved == {"status": "error"}
