Skip to content

Commit 2526e43

Browse files
committed
Add recipients and content assertions to tests
1 parent 5a39f2b commit 2526e43

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
from pydantic import BaseModel
22

33
from onyx.connectors.models import Document
4+
from tests.daily.connectors.utils import to_text_sections
45

56

67
class EmailDoc(BaseModel):
78
subject: str
9+
recipients: set[str]
10+
body: str
811

912
@classmethod
1013
def from_doc(cls, document: Document) -> "EmailDoc":
11-
assert document.title # Acceptable since this will only be used in tests.
14+
# Acceptable to perform assertions since this class is only used in tests.
15+
assert document.title
16+
assert document.external_access
17+
18+
body = " ".join(to_text_sections(iterator=iter(document.sections)))
1219

1320
return cls(
1421
subject=document.title,
22+
recipients=document.external_access.external_user_emails,
23+
body=body,
1524
)

backend/tests/daily/connectors/imap/test_imap_connector.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ def imap_connector() -> ImapConnector:
4949
[
5050
EmailDoc(
5151
subject="Testing",
52+
recipients=set(["admin@onyx-test.com"]),
53+
body="Hello, testing.",
5254
),
5355
EmailDoc(
5456
subject="Hello world",
57+
recipients=set(["admin@onyx-test.com", "r@rabh.io"]),
58+
body='Hello world, this is an email that contains multiple "To" recipients.',
5559
),
5660
]
5761
],

0 commit comments

Comments
 (0)