"""Shared test fixtures for GPS-denied-onboard test suite."""

from unittest.mock import AsyncMock, MagicMock

import numpy as np
import pytest

from gps_denied.core.coordinates import CoordinateTransformer
from gps_denied.core.models import ModelManager
from gps_denied.schemas import CameraParameters, GPSPoint

# ---------------------------------------------------------------
# Common constants
# ---------------------------------------------------------------

TEST_ORIGIN = GPSPoint(lat=49.0, lon=32.0)
TEST_CAMERA = CameraParameters(
    focal_length=4.5,
    sensor_width=6.17,
    sensor_height=4.55,
    resolution_width=640,
    resolution_height=480,
)


# ---------------------------------------------------------------
# Shared fixtures
# ---------------------------------------------------------------

@pytest.fixture
def mock_repo():
    """Mock FlightRepository."""
    return MagicMock()


@pytest.fixture
def mock_streamer():
    """Mock SSEEventStreamer with async push_event."""
    s = MagicMock()
    s.push_event = AsyncMock()
    return s


@pytest.fixture
def model_manager():
    """Singleton ModelManager (mock engines)."""
    return ModelManager()


@pytest.fixture
def coord_transformer():
    """CoordinateTransformer with a preset test ENU origin."""
    ct = CoordinateTransformer()
    ct.set_enu_origin("test_flight", TEST_ORIGIN)
    return ct


@pytest.fixture
def sample_image():
    """Random 200x200 RGB image for pipeline tests."""
    return np.random.randint(0, 255, (200, 200, 3), dtype=np.uint8)
