Skip to content

Commit

Permalink
Merge pull request #4500 from freelawproject/4490-fix-test-docket-and…
Browse files Browse the repository at this point in the history
…-docket-entry-already-exist-assertion

4490 Fixed test_docket_and_docket_entry_already_exist assertion to prevent random failures
  • Loading branch information
mlissner authored Sep 26, 2024
2 parents c2d657c + 3053991 commit 07096ff
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cl/recap/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,8 @@ def test_only_the_docket_already_exists(self) -> None:
Alas, we fail. In theory, this shouldn't happen.
"""
self.de.delete()
rd = async_to_sync(process_recap_pdf)(self.pq.pk)
with mock.patch("cl.recap.tasks.asyncio.sleep"):
rd = async_to_sync(process_recap_pdf)(self.pq.pk)
self.assertIsNone(rd)
self.pq.refresh_from_db()
# Confirm PQ values.
Expand All @@ -1506,7 +1507,9 @@ def test_docket_and_docket_entry_already_exist(self, mock_extract):
self.assertTrue(rd.is_available)
self.assertTrue(rd.sha1)
self.assertTrue(rd.filepath_local)
self.assertIn("gov.uscourts.scotus.asdf.1.0", rd.filepath_local.name)
file_name = rd.filepath_local.name.split("/")[2]
self.assertIn("gov", file_name)
self.assertIn("uscourts.scotus.asdf.1.0", file_name)

mock_extract.assert_called_once()

Expand All @@ -1524,7 +1527,8 @@ def test_nothing_already_exists(self) -> None:
In practice, this shouldn't happen.
"""
self.docket.delete()
rd = async_to_sync(process_recap_pdf)(self.pq.pk)
with mock.patch("cl.recap.tasks.asyncio.sleep"):
rd = async_to_sync(process_recap_pdf)(self.pq.pk)
self.assertIsNone(rd)
self.pq.refresh_from_db()
# Confirm PQ values.
Expand Down

0 comments on commit 07096ff

Please sign in to comment.