"""VCR integration tests for UnpaywallClient."""

from __future__ import annotations

import os
from typing import Any

import pytest

from axm_bib.clients.unpaywall import UnpaywallClient

# During recording, use a real email from env.
# During replay, any email works — VCR intercepts the HTTP call.
_EMAIL = os.environ.get("UNPAYWALL_EMAIL", "vcr-replay@example.com")


@pytest.mark.vcr
class TestUnpaywallVCR:
    """Replay recorded Unpaywall API responses."""

    def test_get_pdf_urls(self, vcr_cassette: Any) -> None:
        """OA URL lookup returns a list of PDF URLs (may be empty)."""
        client = UnpaywallClient(email=_EMAIL)
        urls = client.get_pdf_urls("10.1145/3065386")

        assert isinstance(urls, list)
        # AlexNet paper — well-known, open access
        assert len(urls) > 0
        assert all(isinstance(u, str) for u in urls)
