"""Unit tests for render_prompt_card framing_scale helper consumption."""

import pytest

from app.core.errors import AppError
from app.core.framing_scale import FRAMING_CLOSE, FRAMING_MEDIUM
from app.core.steps.render_prompt_card import _resolve_framing_scale_for_render


def test_resolve_staging_not_applicable_returns_medium_sentinel():
    result = _resolve_framing_scale_for_render(
        staging=None,
        shot_info={"staging_not_applicable": True, "camera_direction": "narrow detail"},
    )
    assert result == FRAMING_MEDIUM


def test_resolve_normal_staging_returns_enum():
    result = _resolve_framing_scale_for_render(
        staging={"framing_scale": "close"},
        shot_info={"camera_direction": "subject fills most of frame"},
    )
    assert result == FRAMING_CLOSE


def test_resolve_missing_staging_without_sentinel_raises():
    with pytest.raises(AppError) as excinfo:
        _resolve_framing_scale_for_render(
            staging=None,
            shot_info={"staging_not_applicable": False},
        )
    assert excinfo.value.code == "shot_staging.framing_scale_missing"


def test_resolve_missing_framing_scale_key_raises():
    with pytest.raises(AppError) as excinfo:
        _resolve_framing_scale_for_render(
            staging={"camera_direction": "subject fills most of frame"},
            shot_info={"camera_direction": "subject fills most of frame"},
        )
    assert excinfo.value.code == "shot_staging.framing_scale_missing"
