Skip to content

Commit

Permalink
add test_handle_bad_provider_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-i committed Nov 11, 2023
1 parent f8d91a7 commit 330f652
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/jupyter-ai/jupyter_ai/tests/test_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import pytest
from unittest.mock import mock_open, patch
from jupyter_ai.config_manager import (
AuthError,
ConfigManager,
Expand Down Expand Up @@ -83,6 +84,11 @@ def reset(config_path, schema_path):
pass


@pytest.fixture
def config_with_bad_provider_ids():
return json.dumps({"model_provider_id:": "foo", "embeddings_provider_id": "bar"})


def configure_to_cohere(cm: ConfigManager):
"""Configures the ConfigManager to use Cohere language and embedding models
with the API key set. Returns a 3-tuple of the keyword arguments used."""
Expand Down Expand Up @@ -290,3 +296,11 @@ def test_forbid_deleting_key_in_use(cm: ConfigManager):

with pytest.raises(KeyInUseError):
cm.delete_api_key("COHERE_API_KEY")


def test_handle_bad_provider_ids(config_with_bad_provider_ids, common_cm_kwargs):
with patch("builtins.open", mock_open(read_data=config_with_bad_provider_ids)):
cm = ConfigManager(**common_cm_kwargs)
config_desc = cm.get_config()
assert config_desc.model_provider_id is None
assert config_desc.embeddings_provider_id is None

0 comments on commit 330f652

Please sign in to comment.