diff --git a/libs/ai-endpoints/tests/unit_tests/conftest.py b/libs/ai-endpoints/tests/unit_tests/conftest.py index 9abdd6b0..8925a6ad 100644 --- a/libs/ai-endpoints/tests/unit_tests/conftest.py +++ b/libs/ai-endpoints/tests/unit_tests/conftest.py @@ -1,4 +1,5 @@ import pytest +import requests_mock from langchain_nvidia_ai_endpoints import ChatNVIDIA, NVIDIAEmbeddings, NVIDIARerank @@ -12,3 +13,8 @@ ) def public_class(request: pytest.FixtureRequest) -> type: return request.param + + +@pytest.fixture +def empty_v1_models(requests_mock: requests_mock.Mocker) -> None: + requests_mock.get("https://integrate.api.nvidia.com/v1/models", json={"data": []}) diff --git a/libs/ai-endpoints/tests/unit_tests/test_chat_models.py b/libs/ai-endpoints/tests/unit_tests/test_chat_models.py index 643f9dd5..1c6ffa72 100644 --- a/libs/ai-endpoints/tests/unit_tests/test_chat_models.py +++ b/libs/ai-endpoints/tests/unit_tests/test_chat_models.py @@ -18,6 +18,6 @@ def test_integration_initialization() -> None: ChatNVIDIA(model="meta/llama2-70b", nvidia_api_key="nvapi-...") -def test_unavailable() -> None: +def test_unavailable(empty_v1_models: None) -> None: with pytest.raises(ValueError): ChatNVIDIA(model="not-a-real-model")