"""Smoke layer (TS-21) — post-install sanity for the `mgf.standard` wheel.

Runs in well under 100 ms and verifies the three things a downstream CI
job wants to pre-flight before kicking off heavier suites:

  (a) the package imports,
  (b) every name in ``__all__`` is reachable on the module,
  (c) the shortest happy path of every public entry function works.

It is deliberately marker-tagged ``smoke`` (TS-20) so a layer can be run
in isolation with ``pytest -m smoke``.
"""

from __future__ import annotations

from pathlib import Path

import pytest

import mgf.standard as ds

pytestmark = pytest.mark.smoke


def test_all_names_are_reachable() -> None:
    # (a) import worked (above); (b) every public name resolves.
    assert ds.__all__, "__all__ is empty"
    missing = [name for name in ds.__all__ if not hasattr(ds, name)]
    assert not missing, f"names in __all__ not reachable on the module: {missing}"


def test_public_happy_paths() -> None:
    # (c) shortest happy path of every public entry function.
    assert isinstance(ds.__version__, str) and ds.__version__

    for dir_fn, list_fn, read_fn in (
        (ds.standards_dir, ds.list_standards, ds.read_standard),
        (ds.recipes_dir, ds.list_recipes, ds.read_recipe),
        (ds.design_dir, ds.list_design, ds.read_design),
    ):
        assert isinstance(dir_fn(), Path) and dir_fn().is_dir()
        names = list_fn()
        assert names, f"{list_fn.__name__} resolved empty"
        assert read_fn(names[0]).strip(), f"{read_fn.__name__}({names[0]!r}) empty"

    assert ds.federation().strip(), "federation() resolved empty"
    assert isinstance(ds.libraries(), list) and ds.libraries()
    assert isinstance(ds.release_waves(), list)
