Ejemplo n.º 1
0
 def test_criminal_data_gets_created(self):
     """Does the criminal data appear in the DB properly when we process
     the docket?
     """
     process_recap_docket(self.pq.pk)
     expected_criminal_count_count = 1
     self.assertEqual(expected_criminal_count_count,
                      CriminalCount.objects.count())
     expected_criminal_complaint_count = 1
     self.assertEqual(expected_criminal_complaint_count,
                      CriminalComplaint.objects.count())
Ejemplo n.º 2
0
    def test_all_entries_ingested_without_duplicates(self):
        """Are all of the docket entries ingested?"""
        expected_entry_count = 23

        pq = self.make_pq()
        returned_data = process_recap_docket(pq.pk)
        d1 = Docket.objects.get(pk=returned_data['docket_pk'])
        self.assertEqual(d1.docket_entries.count(), expected_entry_count)

        pq = self.make_pq()
        returned_data = process_recap_docket(pq.pk)
        d2 = Docket.objects.get(pk=returned_data['docket_pk'])
        self.assertEqual(d1.pk, d2.pk)
        self.assertEqual(d2.docket_entries.count(), expected_entry_count)
Ejemplo n.º 3
0
 def test_debug_does_not_create_docket(self, add_atty_mock):
     """If debug is passed, do we avoid creating a docket?"""
     pq = ProcessingQueue.objects.create(
         court_id='scotus',
         uploader=self.user,
         pacer_case_id='asdf',
         filepath_local=self.docket,
         upload_type=UPLOAD_TYPE.DOCKET,
         debug=True,
     )
     process_recap_docket(pq.pk)
     self.assertEqual(Docket.objects.count(), 0)
     self.assertEqual(DocketEntry.objects.count(), 0)
     self.assertEqual(RECAPDocument.objects.count(), 0)
Ejemplo n.º 4
0
    def test_multiple_numberless_entries_multiple_times(self):
        """Do we get the right number of entries when we add multiple
        numberless entries multiple times?
        """
        expected_entry_count = 25
        pq = self.make_pq('azd_multiple_unnumbered.html')
        returned_data = process_recap_docket(pq.pk)
        d1 = Docket.objects.get(pk=returned_data['docket_pk'])
        self.assertEqual(d1.docket_entries.count(), expected_entry_count)

        pq = self.make_pq('azd_multiple_unnumbered.html')
        returned_data = process_recap_docket(pq.pk)
        d2 = Docket.objects.get(pk=returned_data['docket_pk'])
        self.assertEqual(d1.pk, d2.pk)
        self.assertEqual(d2.docket_entries.count(), expected_entry_count)
Ejemplo n.º 5
0
 def test_docket_and_de_already_exist(self):
     """Can we parse if the docket and the docket entry already exist?"""
     existing_d = Docket.objects.create(
         source=Docket.DEFAULT,
         pacer_case_id='asdf',
         court_id='scotus',
     )
     existing_de = DocketEntry.objects.create(
         docket=existing_d,
         entry_number='1',
         date_filed=date(2008, 1, 1),
     )
     returned_data = process_recap_docket(self.pq.pk)
     d = Docket.objects.get(pk=returned_data['docket_pk'])
     de = d.docket_entries.get(pk=existing_de.pk)
     self.assertNotEqual(
         existing_de.description,
         de.description,
         msg="Description field did not get updated during import.",
     )
     self.assertTrue(
         de.recap_documents.filter(is_available=False).exists(),
         msg="Recap document didn't get created properly.",
     )
     self.assertTrue(d.docket_entries.filter(entry_number='2').exists(),
                     msg="New docket entry didn't get created.")
Ejemplo n.º 6
0
 def test_parsing_docket_does_not_exist(self):
     """Can we parse an HTML docket we have never seen before?"""
     returned_data = process_recap_docket(self.pq.pk)
     d = Docket.objects.get(pk=returned_data['docket_pk'])
     self.assertEqual(d.source, Docket.RECAP)
     self.assertTrue(d.case_name)
     self.assertEqual(d.jury_demand, "None")
Ejemplo n.º 7
0
 def test_docket_and_de_already_exist(self, add_atty_mock):
     """Can we parse if the docket and the docket entry already exist?"""
     existing_d = Docket.objects.create(
         source=Docket.DEFAULT,
         pacer_case_id='asdf',
         court_id='scotus',
     )
     existing_de = DocketEntry.objects.create(
         docket=existing_d,
         entry_number='1',
         date_filed=date(2008, 1, 1),
     )
     d = process_recap_docket(self.pq.pk)
     de = d.docket_entries.get(pk=existing_de.pk)
     self.assertNotEqual(
         existing_de.description,
         de.description,
         msg="Description field did not get updated during import.",
     )
     self.assertTrue(
         de.recap_documents.filter(is_available=False).exists(),
         msg="Recap document didn't get created properly.",
     )
     self.assertTrue(
         d.docket_entries.filter(entry_number='2').exists(),
         msg="New docket entry didn't get created."
     )
Ejemplo n.º 8
0
 def test_parsing_docket_already_exists(self):
     """Can we parse an HTML docket for a docket we have in the DB?"""
     existing_d = Docket.objects.create(
         source=Docket.DEFAULT, pacer_case_id="asdf", court_id="scotus",
     )
     returned_data = process_recap_docket(self.pq.pk)
     d = Docket.objects.get(pk=returned_data["docket_pk"])
     self.assertEqual(d.source, Docket.RECAP_AND_SCRAPER)
     self.assertTrue(d.case_name)
     self.assertEqual(existing_d.pacer_case_id, d.pacer_case_id)
Ejemplo n.º 9
0
 def test_orphan_documents_are_added(self):
     """If there's a pq that exists but previously wasn't processed, do we
     clean it up after we finish adding the docket?
     """
     pq = ProcessingQueue.objects.create(
         court_id="scotus",
         uploader=self.user,
         pacer_case_id="asdf",
         pacer_doc_id="03504231050",
         document_number="1",
         filepath_local=SimpleUploadedFile(
             "file.pdf", b"file content more content",
         ),
         upload_type=UPLOAD_TYPE.PDF,
         status=PROCESSING_STATUS.FAILED,
     )
     process_recap_docket(self.pq.pk)
     pq.refresh_from_db()
     self.assertEqual(pq.status, PROCESSING_STATUS.SUCCESSFUL)
Ejemplo n.º 10
0
 def test_parsing_docket_already_exists(self, add_atty_mock):
     """Can we parse an HTML docket for a docket we have in the DB?"""
     existing_d = Docket.objects.create(
         source=Docket.DEFAULT,
         pacer_case_id='asdf',
         court_id='scotus',
     )
     d = process_recap_docket(self.pq.pk)
     self.assertEqual(d.source, Docket.RECAP_AND_SCRAPER)
     self.assertTrue(d.case_name)
     self.assertEqual(existing_d.pacer_case_id, d.pacer_case_id)
Ejemplo n.º 11
0
 def test_parsing_docket_already_exists(self, add_atty_mock):
     """Can we parse an HTML docket for a docket we have in the DB?"""
     existing_d = Docket.objects.create(
         source=Docket.DEFAULT,
         pacer_case_id='asdf',
         court_id='scotus',
     )
     d = process_recap_docket(self.pq.pk)
     self.assertEqual(d.source, Docket.RECAP_AND_SCRAPER)
     self.assertTrue(d.case_name)
     self.assertEqual(existing_d.pacer_case_id, d.pacer_case_id)
Ejemplo n.º 12
0
 def test_orphan_documents_are_added(self, mock):
     """If there's a pq that exists but previously wasn't processed, do we
     clean it up after we finish adding the docket?
     """
     pq = ProcessingQueue.objects.create(
         court_id='scotus',
         uploader=self.user,
         pacer_case_id='asdf',
         pacer_doc_id='03504231050',
         document_number='1',
         filepath_local=SimpleUploadedFile(
             'file.pdf',
             b"file content more content",
         ),
         upload_type=ProcessingQueue.PDF,
         status=ProcessingQueue.PROCESSING_FAILED,
     )
     process_recap_docket(self.pq.pk)
     pq.refresh_from_db()
     self.assertEqual(pq.status, pq.PROCESSING_SUCCESSFUL)
Ejemplo n.º 13
0
 def test_parsing_docket_does_not_exist(self, add_atty_mock):
     """Can we parse an HTML docket we have never seen before?"""
     d = process_recap_docket(self.pq.pk)
     self.assertEqual(d.source, Docket.RECAP)
     self.assertTrue(d.case_name)
     self.assertEqual(d.jury_demand, "None")
Ejemplo n.º 14
0
 def test_parsing_docket_does_not_exist(self, add_atty_mock):
     """Can we parse an HTML docket we have never seen before?"""
     d = process_recap_docket(self.pq.pk)
     pass