Skip to content

Commit

Permalink
Merge pull request #4391 from ttys0dev/fix-description
Browse files Browse the repository at this point in the history
Don't apply attachment description to main document
  • Loading branch information
mlissner authored Sep 3, 2024
2 parents f5d0067 + 099f41b commit ad6b9f1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cl/recap/mergers.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,10 +954,10 @@ async def add_docket_entries(
await duplicate_rd_queryset.exclude(pk=rd.pk).adelete()

rd.pacer_doc_id = rd.pacer_doc_id or docket_entry["pacer_doc_id"]
description = docket_entry.get("short_description") or rd.description
if rd.document_type == RECAPDocument.PACER_DOCUMENT:
description = docket_entry.get("short_description")
if rd.document_type == RECAPDocument.PACER_DOCUMENT and description:
rd.description = description
else:
elif description:
rd_qs = de.recap_documents.filter(
document_type=RECAPDocument.PACER_DOCUMENT
)
Expand Down
39 changes: 39 additions & 0 deletions cl/recap/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,45 @@ def test_retain_existing_values_in_absent_rss_fields(
self.assertEqual(docket.assigned_to_str, "John Marshall")
self.assertEqual(docket.referred_to_str, "Sophia Clinton")

def test_avoid_deleting_short_description(self) -> None:
"""Test that merging identical docket entries without a
short_description does not delete or overwrite the existing short_description
"""
court_ca10 = CourtFactory(id="ca10", jurisdiction="F")
rss_feed = PacerRssFeed(court_ca10.pk)
with open(self.make_path("rss_ca10.xml"), "rb") as f:
text = f.read().decode()
rss_feed._parse_text(text)
docket = rss_feed.data[0]
d = async_to_sync(find_docket_object)(
court_ca10.pk,
docket["pacer_case_id"],
docket["docket_number"],
docket["federal_defendant_number"],
docket["federal_dn_judge_initials_assigned"],
docket["federal_dn_judge_initials_referred"],
)
async_to_sync(update_docket_metadata)(d, docket)
d.save()
async_to_sync(add_docket_entries)(d, docket["docket_entries"])
rd = RECAPDocument.objects.all().first()
self.assertEqual(rd.description, "Case termination for COA")

# Merge the identical entry without a short_description.
# It should not be removed.
docket_entries = [
MinuteDocketEntryDataFactory(
description="Lorem ipsum",
short_description=None,
pacer_doc_id="010010808570",
document_number="010010808570",
),
]
async_to_sync(add_docket_entries)(d, docket_entries)
rd = RECAPDocument.objects.all().first()
self.assertEqual(d.docket_entries.count(), 1)
self.assertEqual(rd.description, "Case termination for COA")


class DescriptionCleanupTest(SimpleTestCase):
def test_cleanup(self) -> None:
Expand Down

0 comments on commit ad6b9f1

Please sign in to comment.