"""VCR integration tests for ArXivClient."""

from __future__ import annotations

from typing import Any

import pytest

from axm_bib.clients.arxiv import ArXivClient
from axm_bib.models import BibEntry, Paper


@pytest.mark.vcr
class TestArXivVCR:
    """Replay recorded arXiv API responses."""

    def test_bibtex(self, vcr_cassette: Any) -> None:
        """BibTeX fetch returns a valid BibEntry."""
        client = ArXivClient()
        entry = client.bibtex("1706.03762")

        assert isinstance(entry, BibEntry)
        assert entry.raw  # non-empty BibTeX string

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

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