mirror of
https://github.com/deepset-ai/haystack.git
synced 2026-01-08 13:06:29 +00:00
test: monkeypatch OpenAI API key in some unit tests (#9173)
This commit is contained in:
parent
d977b262b6
commit
c6df8d2c7a
@ -80,7 +80,8 @@ class TestContextRelevanceEvaluator:
|
||||
assert component._chat_generator.client.api_key == "test-api-key"
|
||||
assert component._chat_generator.generation_kwargs == {"response_format": {"type": "json_object"}, "seed": 42}
|
||||
|
||||
def test_init_with_chat_generator(self):
|
||||
def test_init_with_chat_generator(self, monkeypatch):
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "test-api-key")
|
||||
chat_generator = OpenAIChatGenerator(generation_kwargs={"response_format": {"type": "json_object"}, "seed": 42})
|
||||
component = ContextRelevanceEvaluator(chat_generator=chat_generator)
|
||||
|
||||
|
||||
@ -100,7 +100,8 @@ class TestFaithfulnessEvaluator:
|
||||
assert component._chat_generator.client.api_key == "test-api-key"
|
||||
assert component._chat_generator.generation_kwargs == {"response_format": {"type": "json_object"}, "seed": 42}
|
||||
|
||||
def test_init_with_chat_generator(self):
|
||||
def test_init_with_chat_generator(self, monkeypatch):
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "test-api-key")
|
||||
chat_generator = OpenAIChatGenerator(generation_kwargs={"response_format": {"type": "json_object"}, "seed": 42})
|
||||
component = FaithfulnessEvaluator(chat_generator=chat_generator)
|
||||
|
||||
|
||||
@ -98,7 +98,8 @@ class TestDeserializeDocumentStoreInInitParamsInplace:
|
||||
|
||||
|
||||
class TestDeserializeChatGeneratorInplace:
|
||||
def test_deserialize_chatgenerator_inplace(self):
|
||||
def test_deserialize_chatgenerator_inplace(self, monkeypatch):
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "test-api-key")
|
||||
chat_generator = OpenAIChatGenerator()
|
||||
data = {"chat_generator": chat_generator.to_dict()}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user