Skip to content

Commit 620b5ce

Browse files
committed
fix: skip OpenAI unittests if api key is not configured
1 parent e1d807b commit 620b5ce

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

toolium/test/utils/ai_utils/test_text_similarity.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""
1818

1919
import mock
20+
import os
2021
import pytest
2122

2223
from toolium.driver_wrappers_pool import DriverWrappersPool
@@ -68,6 +69,8 @@ def test_get_text_similarity_with_sentence_transformers(input_text, expected_tex
6869
)
6970

7071

72+
@pytest.mark.skipif(os.getenv("AZURE_OPENAI_API_KEY") is None,
73+
reason="AZURE_OPENAI_API_KEY environment variable not set")
7174
@pytest.mark.parametrize('input_text, expected_text, expected_low, expected_high', get_openai_similarity_examples)
7275
def test_get_text_similarity_with_azure_openai(input_text, expected_text, expected_low, expected_high):
7376
configure_default_openai_model()
@@ -93,6 +96,8 @@ def test_assert_text_similarity_with_sentence_transformers_passed(input_text, ex
9396
assert_text_similarity(input_text, expected_text, threshold=threshold, similarity_method='sentence_transformers')
9497

9598

99+
@pytest.mark.skipif(os.getenv("AZURE_OPENAI_API_KEY") is None,
100+
reason="AZURE_OPENAI_API_KEY environment variable not set")
96101
@pytest.mark.parametrize('input_text, expected_text, threshold', assert_similarity_passed_examples)
97102
def test_assert_text_similarity_with_openai_passed(input_text, expected_text, threshold):
98103
configure_default_openai_model()
@@ -126,6 +131,8 @@ def test_assert_text_similarity_with_sentence_transformers_failed(input_text, ex
126131
)
127132

128133

134+
@pytest.mark.skipif(os.getenv("AZURE_OPENAI_API_KEY") is None,
135+
reason="AZURE_OPENAI_API_KEY environment variable not set")
129136
@pytest.mark.parametrize('input_text, expected_text, threshold', assert_openai_similarity_failed_examples)
130137
def test_assert_text_similarity_with_openai_failed(input_text, expected_text, threshold):
131138
configure_default_openai_model()

0 commit comments

Comments
 (0)