Skip to content

Commit

Permalink
feat(search): Add test for dockets without documents
Browse files Browse the repository at this point in the history
  • Loading branch information
ERosendo committed Mar 11, 2025
1 parent e26cb76 commit 50fbe52
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions cl/search/tests/tests_es_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from cl.lib.search_utils import fetch_es_results_for_csv
from cl.lib.test_helpers import RECAPSearchTestCase
from cl.search.models import SEARCH_TYPES
from cl.search.factories import DocketFactory
from cl.search.models import SEARCH_TYPES, Docket
from cl.tests.cases import ESIndexTestCase, TestCase
from cl.users.factories import UserProfileWithParentsFactory

Expand All @@ -21,6 +22,15 @@ class ExportSearchTest(RECAPSearchTestCase, ESIndexTestCase, TestCase):
@classmethod
def setUpTestData(cls):
cls.user_profile = UserProfileWithParentsFactory()
cls.no_doc_docket = (
DocketFactory(
case_name_short="Wu",
case_name_full="Wu v. Lipo Flavonoid LLC",
docket_number="1:25-cv-01363",
source=Docket.RECAP,
cause="443 Civil Rights: Accommodations",
),
)
cls.rebuild_index("search.Docket")
super().setUpTestData()
cls.rebuild_index("people_db.Person")
Expand Down Expand Up @@ -103,8 +113,22 @@ def test_do_not_send_empty_emails(self) -> None:
)
self.assertEqual(len(mail.outbox), 0)

def test_can_send_email_with_docket_no_child(self) -> None:
"Confirms we can send emails when the document has no child"
self.client.login(
username=self.user_profile.user.username, password="password"
)
self.client.post(
reverse("export_search_results"), {"query": 'q="Wu"&type=r'}
)
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(
mail.outbox[0].subject, "Your Search Results are Ready!"
)
self.assertEqual(mail.outbox[0].to[0], self.user_profile.user.email)

def test_sends_email_with_attachment(self) -> None:
"Confirms we dont send emails when provided with invalid query"
"Confirms we can send emails when the query is correct"
self.client.login(
username=self.user_profile.user.username, password="password"
)
Expand Down

0 comments on commit 50fbe52

Please sign in to comment.