"""VCR integration tests for DBLPClient."""

from __future__ import annotations

from typing import Any

import pytest

from axm_bib.clients.dblp import DBLPClient
from axm_bib.models import BibEntry, Paper


@pytest.mark.vcr
class TestDBLPVCR:
    """Replay recorded DBLP API responses."""

    def test_search(self, vcr_cassette: Any) -> None:
        """Search returns parsed Paper objects from real API response."""
        client = DBLPClient()
        papers = client.search("attention transformer", limit=3)

        assert isinstance(papers, list)
        assert len(papers) > 0
        assert all(isinstance(p, Paper) for p in papers)
        assert all(p.source == "dblp" for p in papers)

    def test_bibtex(self, vcr_cassette: Any) -> None:
        """BibTeX fetch returns a valid BibEntry."""
        client = DBLPClient()
        entry = client.bibtex("conf/nips/VaswaniSPUJGKP17")

        assert isinstance(entry, BibEntry)
        assert entry.raw  # non-empty BibTeX string
        assert "vaswani" in entry.raw.lower() or "attention" in entry.raw.lower()
