Skip to content

Commit

Permalink
mock open ai key
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebCourier committed Dec 12, 2023
1 parent 3e8502a commit 7013d36
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/unit_tests/test_llm_providers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib.util
import os
from typing import Any, Callable, Dict, Iterable
from unittest.mock import MagicMock

Expand All @@ -14,6 +15,7 @@
get_llm_ask,
)
from guardrails.utils.openai_utils import OPENAI_VERSION
from guardrails.utils.safe_get import safe_get_with_brackets

from .mocks import MockAsyncOpenAILlm, MockOpenAILlm

Expand Down Expand Up @@ -593,7 +595,14 @@ def test_get_llm_ask_openai_chat():
not importlib.util.find_spec("manifest"),
reason="manifest is not installed",
)
def test_get_llm_ask_manifest():
def test_get_llm_ask_manifest(mocker):
def mock_os_environ_get(key, *args):
if key == "OPENAI_API_KEY":
return "sk-xxxxxxxxxxxxxx"
return safe_get_with_brackets(os.environ, key, *args)

mocker.patch("os.environ.get", side_effect=mock_os_environ_get)

from manifest import Manifest

from guardrails.llm_providers import ManifestCallable
Expand Down

0 comments on commit 7013d36

Please sign in to comment.