mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Add online search chat director tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# Standard Packages
|
# Standard Packages
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
# External Packages
|
# External Packages
|
||||||
import pytest
|
import pytest
|
||||||
@@ -54,6 +55,26 @@ def test_chat_with_no_chat_history_or_retrieved_content_gpt4all(client_offline_c
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
@pytest.mark.chatquality
|
||||||
|
@pytest.mark.django_db(transaction=True)
|
||||||
|
def test_chat_with_online_content(chat_client):
|
||||||
|
# Act
|
||||||
|
q = "/online give me the link to paul graham's essay how to do great work"
|
||||||
|
encoded_q = quote(q, safe="")
|
||||||
|
response = chat_client.get(f"/api/chat?q={encoded_q}&stream=true")
|
||||||
|
response_message = response.content.decode("utf-8")
|
||||||
|
|
||||||
|
response_message = response_message.split("### compiled references")[0]
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
expected_responses = ["http://www.paulgraham.com/greatwork.html"]
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert any([expected_response in response_message for expected_response in expected_responses]), (
|
||||||
|
"Expected assistants name, [K|k]hoj, in response but got: " + response_message
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
@pytest.mark.chatquality
|
@pytest.mark.chatquality
|
||||||
@pytest.mark.django_db(transaction=True)
|
@pytest.mark.django_db(transaction=True)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Standard Packages
|
# Standard Packages
|
||||||
import os
|
import os
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
# External Packages
|
# External Packages
|
||||||
import pytest
|
import pytest
|
||||||
@@ -54,6 +55,26 @@ def test_chat_with_no_chat_history_or_retrieved_content(chat_client):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
@pytest.mark.chatquality
|
||||||
|
@pytest.mark.django_db(transaction=True)
|
||||||
|
def test_chat_with_online_content(chat_client):
|
||||||
|
# Act
|
||||||
|
q = "/online give me the link to paul graham's essay how to do great work"
|
||||||
|
encoded_q = quote(q, safe="")
|
||||||
|
response = chat_client.get(f"/api/chat?q={encoded_q}&stream=true")
|
||||||
|
response_message = response.content.decode("utf-8")
|
||||||
|
|
||||||
|
response_message = response_message.split("### compiled references")[0]
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
expected_responses = ["http://www.paulgraham.com/greatwork.html"]
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert any([expected_response in response_message for expected_response in expected_responses]), (
|
||||||
|
"Expected assistants name, [K|k]hoj, in response but got: " + response_message
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
@pytest.mark.django_db(transaction=True)
|
@pytest.mark.django_db(transaction=True)
|
||||||
@pytest.mark.chatquality
|
@pytest.mark.chatquality
|
||||||
|
|||||||
Reference in New Issue
Block a user