import pytest

from m3m_twin.specs import MAVIC_3M, mapping_geometry


def test_current_band_centres_are_recorded():
    assert MAVIC_3M.band_green_nm == "560±16"
    assert MAVIC_3M.band_nir_nm == "860±26"


def test_five_camera_file_set_is_one_plus_four():
    assert MAVIC_3M.multispectral_camera_count + 1 == 5


def test_sixty_metre_gsd_uses_official_formula():
    geometry = mapping_geometry(60, 80, 70)
    assert geometry["rgbGsdCmPerPixel"] == pytest.approx(1.612903, abs=1e-6)
    assert geometry["multispectralGsdCmPerPixel"] == pytest.approx(2.764977, abs=1e-6)


def test_sixty_metre_footprint():
    geometry = mapping_geometry(60, 80, 70)
    assert geometry["multispectralFootprintCrossTrackM"] == pytest.approx(71.668203, abs=1e-6)
    assert geometry["multispectralFootprintAlongTrackM"] == pytest.approx(53.751152, abs=1e-6)


@pytest.mark.parametrize("front,side", [(0, 70), (80, 100), (-1, 70)])
def test_invalid_overlap_is_rejected(front, side):
    with pytest.raises(ValueError):
        mapping_geometry(60, front, side)


def test_spec_receipt_discloses_official_conflict():
    receipt = MAVIC_3M.as_receipt()
    assert "5.5 MP" in receipt["conflictResolution"]
    assert "stale FAQ" in receipt["conflictResolution"]
