"""Tests para add_basemap_with_timeout."""

import sys
from pathlib import Path

import matplotlib
matplotlib.use("Agg")

sys.path.insert(0, str(Path(__file__).parent.parent.parent))

from geo.add_basemap_with_timeout import add_basemap_with_timeout


def test_timeout_muy_corto_retorna_False_sin_colgar():
    import matplotlib.pyplot as plt

    fig, ax = plt.subplots()
    ax.set_xlim(-430000, -350000)
    ax.set_ylim(4500000, 4600000)
    # 0.001 s timeout — should fail/timeout fast and return False
    result = add_basemap_with_timeout(ax, zoom=9, timeout_s=0.001)
    plt.close(fig)
    assert result is False, f"expected False with 0.001s timeout, got {result}"
