"""Tests for DatasetAdapter base contract."""

import pytest

from gps_denied.testing.datasets.base import (
    DatasetAdapter,
    DatasetCapabilities,
    DatasetFrame,
    DatasetIMU,
    DatasetNotAvailableError,
    DatasetPose,
    PlatformClass,
)


def test_capabilities_defaults():
    cap = DatasetCapabilities(
        has_raw_imu=False,
        has_rtk_gt=False,
        has_loop_closures=False,
        platform_class=PlatformClass.FIXED_WING,
    )
    assert cap.has_raw_imu is False
    assert cap.platform_class == PlatformClass.FIXED_WING


def test_adapter_is_abstract():
    with pytest.raises(TypeError):
        DatasetAdapter()  # type: ignore[abstract]


def test_dataset_not_available_error_is_exception():
    assert issubclass(DatasetNotAvailableError, Exception)


def test_dataset_frame_dataclass_fields():
    frame = DatasetFrame(
        frame_idx=0,
        timestamp_ns=1_000_000_000,
        image_path="/tmp/x.jpg",
    )
    assert frame.frame_idx == 0
    assert frame.timestamp_ns == 1_000_000_000


def test_dataset_imu_dataclass_fields():
    imu = DatasetIMU(
        timestamp_ns=1_000_000_000,
        accel=(0.0, 0.0, -9.81),
        gyro=(0.0, 0.0, 0.0),
    )
    assert imu.accel == (0.0, 0.0, -9.81)


def test_dataset_pose_dataclass_fields():
    pose = DatasetPose(
        timestamp_ns=1_000_000_000,
        lat=49.0,
        lon=32.0,
        alt=100.0,
        qx=0.0, qy=0.0, qz=0.0, qw=1.0,
    )
    assert pose.lat == 49.0
