mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-04 03:59:25 +02:00
Add assertions to Zendesk connector tests (#3600)
Co-authored-by: hagen-danswer <hagen@danswer.ai>
This commit is contained in:
parent
c2444a5cff
commit
143be6a524
@ -5,9 +5,9 @@ from pathlib import Path
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from danswer.configs.constants import DocumentSource
|
from onyx.configs.constants import DocumentSource
|
||||||
from danswer.connectors.models import Document
|
from onyx.connectors.models import Document
|
||||||
from danswer.connectors.zendesk.connector import ZendeskConnector
|
from onyx.connectors.zendesk.connector import ZendeskConnector
|
||||||
|
|
||||||
|
|
||||||
def load_test_data(file_name: str = "test_zendesk_data.json") -> dict[str, dict]:
|
def load_test_data(file_name: str = "test_zendesk_data.json") -> dict[str, dict]:
|
||||||
@ -60,6 +60,7 @@ def test_zendesk_connector_basic(
|
|||||||
all_docs.append(doc)
|
all_docs.append(doc)
|
||||||
if doc.id == target_test_doc_id:
|
if doc.id == target_test_doc_id:
|
||||||
target_doc = doc
|
target_doc = doc
|
||||||
|
print(f"target_doc {target_doc}")
|
||||||
|
|
||||||
assert len(all_docs) > 0, "No documents were retrieved from the connector"
|
assert len(all_docs) > 0, "No documents were retrieved from the connector"
|
||||||
assert (
|
assert (
|
||||||
@ -68,15 +69,29 @@ def test_zendesk_connector_basic(
|
|||||||
assert target_doc.source == DocumentSource.ZENDESK, "Document source is not ZENDESK"
|
assert target_doc.source == DocumentSource.ZENDESK, "Document source is not ZENDESK"
|
||||||
|
|
||||||
if connector.content_type == "articles":
|
if connector.content_type == "articles":
|
||||||
print(f"target_doc.semantic_identifier {target_doc.semantic_identifier}")
|
test_article = test_data["article"]
|
||||||
|
assert target_doc.semantic_identifier == test_article["semantic_identifier"]
|
||||||
|
assert target_doc.sections[0].link == test_article["sections"][0]["link"]
|
||||||
|
assert target_doc.source == test_article["source"]
|
||||||
assert (
|
assert (
|
||||||
target_doc.semantic_identifier
|
target_doc.primary_owners[0].display_name
|
||||||
== test_data["article"]["semantic_identifier"]
|
== test_article["primary_owners"][0]["display_name"]
|
||||||
), "Article title does not match"
|
)
|
||||||
|
assert (
|
||||||
|
target_doc.primary_owners[0].email
|
||||||
|
== test_article["primary_owners"][0]["email"]
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
assert target_doc.semantic_identifier.startswith(
|
test_ticket = test_data["ticket"]
|
||||||
f"Ticket #{test_data['ticket']['id']}"
|
assert target_doc.semantic_identifier == test_ticket["semantic_identifier"]
|
||||||
), "Ticket ID does not match"
|
assert target_doc.sections[0].link == test_ticket["sections"][0]["link"]
|
||||||
|
assert target_doc.source == test_ticket["source"]
|
||||||
|
assert target_doc.metadata["status"] == test_ticket["metadata"]["status"]
|
||||||
|
assert target_doc.metadata["priority"] == test_ticket["metadata"]["priority"]
|
||||||
|
assert target_doc.metadata["tags"] == test_ticket["metadata"]["tags"]
|
||||||
|
assert (
|
||||||
|
target_doc.metadata["ticket_type"] == test_ticket["metadata"]["ticket_type"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_zendesk_connector_slim(zendesk_article_connector: ZendeskConnector) -> None:
|
def test_zendesk_connector_slim(zendesk_article_connector: ZendeskConnector) -> None:
|
||||||
|
@ -1,11 +1,34 @@
|
|||||||
{
|
{
|
||||||
"article": {
|
"article": {
|
||||||
"id": "17275801227804",
|
"id": "32502691728155",
|
||||||
"semantic_identifier": "How can agents leverage knowledge to help customers?"
|
"sections": [
|
||||||
|
{
|
||||||
},
|
"link": "https://d3v-onyx.zendesk.com/hc/en-us/articles/32502691728155-How-can-agents-leverage-knowledge-to-help-customers"
|
||||||
"ticket": {
|
}
|
||||||
"id": "1"
|
],
|
||||||
|
"source": "zendesk",
|
||||||
|
"semantic_identifier": "How can agents leverage knowledge to help customers?",
|
||||||
|
"primary_owners": [
|
||||||
|
{
|
||||||
|
"display_name": "Dan Swer",
|
||||||
|
"email": "admin@onyx-test.com"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ticket": {
|
||||||
|
"id": "1",
|
||||||
|
"sections": [
|
||||||
|
{
|
||||||
|
"link": "https://d3v-onyx.zendesk.com/agent/tickets/1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": "zendesk",
|
||||||
|
"semantic_identifier": "Ticket #1: SAMPLE TICKET: Meet the ticket",
|
||||||
|
"metadata": {
|
||||||
|
"status": "open",
|
||||||
|
"priority": "normal",
|
||||||
|
"tags": ["sample", "support", "zendesk"],
|
||||||
|
"ticket_type": "incident"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user