from __future__ import annotations

from pathlib import Path

import cv2
import numpy as np
import pytest

import mlx_vision as mv


def test_is_vision_available_returns_bool() -> None:
    assert isinstance(mv.is_vision_available(), bool)


def test_vision_functions_raise_without_framework(tmp_path: Path) -> None:
    if mv.is_vision_available():
        pytest.skip("Vision framework is available")

    image_path = tmp_path / "img.jpg"
    cv2.imwrite(str(image_path), np.zeros((32, 32, 3), dtype=np.uint8))

    with pytest.raises(ImportError):
        mv.detect_faces(image_path)

    with pytest.raises(ImportError):
        mv.detect_text(image_path)

    with pytest.raises(ImportError):
        mv.classify_image(image_path)

    with pytest.raises(ImportError):
        mv.saliency_map(image_path)
