"""Tests pour les endpoints de logs API."""

from pricewatch.app.api.main import list_backend_logs, BACKEND_LOGS
from pricewatch.app.api.schemas import BackendLogEntry


def test_list_backend_logs_empty():
    """Liste des logs backend vide."""
    BACKEND_LOGS.clear()
    result = list_backend_logs()
    assert result == []


def test_list_backend_logs_with_entries():
    """Liste des logs backend avec entrees."""
    from datetime import datetime
    BACKEND_LOGS.clear()
    entry = BackendLogEntry(level="INFO", message="Test log", time=datetime(2026, 1, 17, 12, 0, 0))
    BACKEND_LOGS.append(entry)

    result = list_backend_logs()
    assert len(result) == 1
    assert result[0].message == "Test log"
    assert result[0].level == "INFO"

    BACKEND_LOGS.clear()
