mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Only run the OpenAI chat client, /online test when API keys are set
This commit is contained in:
parent
7039c202c8
commit
d26a4ffcea
2 changed files with 4 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
# Standard Modules
|
# Standard Modules
|
||||||
|
import os
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
|
@ -461,6 +462,7 @@ def test_user_no_data_returns_empty(client, sample_org_data, api_user3: KhojApiU
|
||||||
assert response.json() == []
|
assert response.json() == []
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(os.getenv("OPENAI_API_KEY") is None, reason="requires OPENAI_API_KEY")
|
||||||
@pytest.mark.django_db(transaction=True)
|
@pytest.mark.django_db(transaction=True)
|
||||||
def test_chat_with_unauthenticated_user(chat_client_with_auth, api_user2: KhojApiUser):
|
def test_chat_with_unauthenticated_user(chat_client_with_auth, api_user2: KhojApiUser):
|
||||||
# Arrange
|
# Arrange
|
||||||
|
|
|
@ -53,6 +53,7 @@ def test_chat_with_no_chat_history_or_retrieved_content(chat_client):
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
@pytest.mark.skipif(os.getenv("SERPER_DEV_API_KEY") is None, reason="requires SERPER_DEV_API_KEY")
|
||||||
@pytest.mark.chatquality
|
@pytest.mark.chatquality
|
||||||
@pytest.mark.django_db(transaction=True)
|
@pytest.mark.django_db(transaction=True)
|
||||||
def test_chat_with_online_content(chat_client):
|
def test_chat_with_online_content(chat_client):
|
||||||
|
@ -65,7 +66,7 @@ def test_chat_with_online_content(chat_client):
|
||||||
response_message = response_message.split("### compiled references")[0]
|
response_message = response_message.split("### compiled references")[0]
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
expected_responses = ["http://www.paulgraham.com/greatwork.html", "Please set your SERPER_DEV_API_KEY"]
|
expected_responses = ["http://www.paulgraham.com/greatwork.html"]
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert any([expected_response in response_message for expected_response in expected_responses]), (
|
assert any([expected_response in response_message for expected_response in expected_responses]), (
|
||||||
"Expected links or serper not setup in response but got: " + response_message
|
"Expected links or serper not setup in response but got: " + response_message
|
||||||
|
|
Loading…
Reference in a new issue