Skip to content

Commit

Permalink
add empty /v1/models fixture to ensure unit tests run without network…
Browse files Browse the repository at this point in the history
… connectivity
  • Loading branch information
mattf committed Jul 19, 2024
1 parent 17d0008 commit c265121
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions libs/ai-endpoints/tests/unit_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import requests_mock

from langchain_nvidia_ai_endpoints import ChatNVIDIA, NVIDIAEmbeddings, NVIDIARerank

Expand All @@ -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": []})
2 changes: 1 addition & 1 deletion libs/ai-endpoints/tests/unit_tests/test_chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit c265121

Please sign in to comment.