"""Tests para add_header_logo."""
from __future__ import annotations

from pathlib import Path

import matplotlib
matplotlib.use("Agg")
import numpy as np
import pytest


def test_figura_nueva_con_imagen_zeros_no_lanza_excepcion():
    """figura nueva con imagen zeros no lanza excepcion"""
    import sys
    sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
    from infra.add_header_logo import add_header_logo
    import matplotlib.pyplot as plt

    fig, ax = plt.subplots(figsize=(11.69, 8.27))
    image = np.zeros((50, 200, 3), dtype=np.uint8)

    # Should not raise
    add_header_logo(fig, image)
    plt.close(fig)


def test_axes_de_logo_tiene_axis_off():
    """axes de logo tiene axis off"""
    import sys
    sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
    from infra.add_header_logo import add_header_logo
    import matplotlib.pyplot as plt

    fig, ax = plt.subplots(figsize=(11.69, 8.27))
    initial_axes_count = len(fig.axes)
    image = np.zeros((10, 10, 3), dtype=np.uint8)

    add_header_logo(fig, image, x=0.88, y=0.905, width=0.08, height=0.08)

    # A new axes should have been added
    assert len(fig.axes) == initial_axes_count + 1
    logo_ax = fig.axes[-1]
    # axis("off") disables both x and y axis visibility
    assert not logo_ax.axison
    plt.close(fig)
