Skip to content

Commit

Permalink
tests(recap): Add test for handling failed purchase logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ERosendo committed Jan 24, 2025
1 parent 812ff64 commit 0f6ad2e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cl/recap/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,27 @@ def test_avoid_purchasing_acms_document(
fq_acms.message,
)

@mock.patch(
"cl.recap.tasks.download_pacer_pdf_by_rd",
return_value=(None, "Unable to download PDF."),
)
def test_handle_failed_purchases(
self, mock_download_method, mock_court_accessible, mock_get_cookies
):
"""Can we handle failed purchases?"""
self.rd.is_available = False
self.rd.save()

self.assertFalse(self.rd.is_available)
fetch_pacer_doc_by_rd(self.rd.pk, self.fq.pk)

self.fq.refresh_from_db()
self.assertEqual(self.fq.status, PROCESSING_STATUS.FAILED)
self.assertIn(
"Unable to download PDF.",
self.fq.message,
)


@mock.patch(
"cl.recap.tasks.is_pacer_court_accessible",
Expand Down

0 comments on commit 0f6ad2e

Please sign in to comment.