def test_skip_empty(self): key_mapping_file = os.path.join(os.path.dirname(__file__), 'fixtures/skip_empty.yaml') extractor = JsonDataExtractor(key_mapping_file) expected = IngestInfo() expected.create_person( full_name='skip empty', bookings=[ Booking( custody_status='in custody', booking_id='1', charges=[ Charge(name="battery", ), Charge( name="assault", charge_class='misdemeanor', ), ], ), Booking( booking_id='2', charges=[ Charge( name='robbery', charge_class='felony', ), ], ), ], ) result = extractor.extract_and_populate_data(_SKIP_EMPTY) self.assertEqual(result, expected)
def testParseColFail(self): expected_info = IngestInfo(people=[ Person(person_id='100041685', gender='M', age='41', race='AMERICAN INDIAN', bookings=[ Booking( booking_id='130877687', admission_date='02/27/2020 14:51', custody_status='IN CUSTODY', facility='BERNALILLO COUNTY METRO DETENTION CENTER', arrest=Arrest(agency='/BSO', ), charges=[ Charge( offense_date='02/27/2020', name='FAIL TO COMPLY', case_number='D202CR201802134', ), Charge( offense_date='02/27/2020', name='AGGRAVATED DWI-3', case_number='D202CR201802134', ), ]) ]), ]) with pytest.raises(DirectIngestError) as e: self.run_parse_file_test(expected_info, 'MDC_VERA_20200303_02') assert str(e.value) == "Found more columns than expected in charge row"
def test_skip_empty(self) -> None: key_mapping_file = os.path.join( os.path.dirname(__file__), "fixtures/skip_empty.yaml" ) extractor = JsonDataExtractor(key_mapping_file) expected = IngestInfo() expected.create_person( full_name="skip empty", bookings=[ Booking( custody_status="in custody", booking_id="1", charges=[ Charge( name="battery", ), Charge( name="assault", charge_class="misdemeanor", ), ], ), Booking( booking_id="2", charges=[ Charge( name="robbery", charge_class="felony", ), ], ), ], ) result = extractor.extract_and_populate_data( fixtures.as_dict("extractor", "skip_empty.json") ) self.assertEqual(result, expected)
def testParse(self): expected_info = IngestInfo( people=[ Person( person_id='100041685', gender='M', age='41', race='AMERICAN INDIAN', bookings=[Booking( booking_id='130877687', admission_date='02/27/2020 14:51', custody_status='IN CUSTODY', facility='BERNALILLO COUNTY METRO DETENTION CENTER', arrest=Arrest( agency='/BSO', ), charges=[ Charge( offense_date='02/27/2020', name='FAIL TO COMPLY', case_number='D202CR201802134', bond=Bond(amount='0', bond_type='HOLD') ), Charge( offense_date='02/27/2020', name='AGGRAVATED DWI-3', case_number='D202CR201802134', bond=Bond(amount='0', bond_type='HOLD') ), ] )] ), Person( person_id='100044962', gender='M', age='42', race='HISPANIC', bookings=[Booking( booking_id='130847497', admission_date='12/18/2018 01:21', custody_status='IN CUSTODY', facility='BERNALILLO COUNTY METRO DETENTION CENTER', arrest=Arrest( agency='/APD/BCDC', ), charges=[ Charge( offense_date='01/07/2019', name='GRAND JURY INDICTMENT', case_number='D202CR2019000032', bond=Bond(amount='0', bond_type='CONCURRENT', status='Active') ), Charge( offense_date='01/07/2019', name='AGG BATTERY W/DEADLY WEAPON', case_number='D202CR2019000032', bond=Bond(amount='0', bond_type='CONCURRENT', status='Active') ), ] )] ), Person( person_id='100265415', gender='M', age='35', race='WHITE', bookings=[Booking( booking_id='130877954', admission_date='03/02/2020 18:54', custody_status='IN CUSTODY', facility='BERNALILLO COUNTY METRO DETENTION CENTER', arrest=Arrest( agency='/APD', ), charges=[ Charge( bond=Bond(amount='0', bond_type='To be set by Judge') ), ] )] ), Person( person_id='100265416', gender='M', age='35', race='WHITE', bookings=[Booking( booking_id='130877955', admission_date='03/02/2020 18:54', custody_status='IN CUSTODY', facility='BERNALILLO COUNTY METRO DETENTION CENTER', arrest=Arrest( agency='/APD', ), charges=[ Charge( bond=Bond(amount='0', bond_type='RELEASE ON RECOG') ), ] )] ), Person( person_id='100265417', gender='M', age='35', race='WHITE', bookings=[Booking( booking_id='130877956', admission_date='03/02/2020 18:54', custody_status='IN CUSTODY', facility='BERNALILLO COUNTY METRO DETENTION CENTER', arrest=Arrest( agency='/APD', ), charges=[ Charge( bond=Bond(amount='0', bond_type='THIRD PARTY') ), ] )] ), ] ) ingest_info = self.run_parse_file_test(expected_info, 'MDC_VERA_20200303_01') region = regions.get_region(self.region_code(), is_direct_ingest=True) metadata = IngestMetadata( region.region_code, region.jurisdiction_id, _FAKE_START_TIME, self.controller.get_enum_overrides(), ) self.validate_ingest(ingest_info, expected_info, metadata)
def testParse(self): expected_info = IngestInfo( people=[ Person( person_id='12345', birthdate='8/10/1987 12:00:00 AM', gender='M ', race='White', place_of_residence='Brazos', bookings=[ Booking( booking_id='321 (Individual ID: 12345)', admission_date='3/31/2019 12:00:00 AM', custody_status= 'L. Pretrial State Jail Felons (SJF)', facility='BCDC', arrest=Arrest( agency="College Station Police Department"), charges=[ Charge( charge_id='1', offense_date='3/25/2019 12:00:00 AM', statute='481.121(B)(1) HSC', name='POSS MARIJ <2OZ', charge_notes='17.16 DET PEND ORD', level='B', charge_class='MIS', status='Intake', bond=Bond( bond_id='1', amount='2000.0000', bond_type='Surety Bond', status='Posted')), Charge( charge_id='2', offense_date='3/25/2019 12:00:00 AM', statute='483.041 HSC', name='POSS DANGEROUS DRUG', charge_notes='17.16 DET PEND ORD', level='A', charge_class='MIS', status='Intake', bond=Bond( bond_id='2', amount='4000.0000', bond_type='Surety Bond', status='Posted')), Charge( charge_id='3', offense_date='1/20/2019 12:00:00 AM', statute='31.03(e)(2)(A)', name='THEFT PROP >=$100<$750', level='B', charge_class='MIS', status='Accepted'), Charge( charge_id='4', offense_date='3/30/2019 12:00:00 AM', statute='30.02(C)(1) PC', name='BURGLARY OF BUILDING', level='State Jail Felony', charge_class='FEL', status='Warrant Issued'), Charge( charge_id='5', offense_date='3/25/2019 12:00:00 AM', statute='481.116(B) HSC', name='POSS CS PG 2 LESS THAN ONE GRAM', level='State Jail Felony', charge_class='FEL', status='Warrant Issued'), Charge( charge_id='6', offense_date='3/23/2019 12:00:00 AM', statute='30.02(C)(1) PC', name='BURGLARY OF BUILDING', level='State Jail Felony', charge_class='FEL', status='Warrant Issued'), Charge( charge_id='7', offense_date='3/24/2019 12:00:00 AM', statute='30.02(C)(1) PC', name='BURGLARY OF BUILDING', level='State Jail Felony', charge_class='FEL', status='Warrant Issued')])]), Person( person_id='23456', birthdate='2/21/1982 12:00:00 AM', gender='M ', race='Black', place_of_residence='Brazos', bookings=[ Booking( booking_id='432 (Individual ID: 23456)', admission_date='5/14/2018 12:00:00 AM', custody_status= 'L. Pretrial State Jail Felons (SJF)', facility='BCDC', arrest=Arrest( agency="Unlisted"), charges=[ Charge( charge_id='8', name='Parole Violation/Bl/Wrnt/tty', degree='Felony Unassigned', charge_class='FEL'), Charge( charge_id='9', offense_date='5/14/2018 12:00:00 AM', statute='38.04(B)(1) PC', name='EVADING ARREST DET W/PREV CONVICTION', level='State Jail Felony', charge_class='FEL', status='Defendant Indicted'), Charge( charge_id='10', statute='NON REPORTABLE', name='Awaiting Trans To Dept State ' 'Health Services', degree='Not Applicable', bond=Bond(bond_id='2', amount='20'))], holds=[ Hold( jurisdiction_name='TDC Hold')])])]) ingest_info = self.run_parse_file_test( expected_info, 'VERABrazosJailData_01012019_115703') region = regions.get_region(self.region_code(), is_direct_ingest=True) metadata = IngestMetadata( region.region_code, region.jurisdiction_id, _FAKE_START_TIME, self.controller.get_enum_overrides(), ) self.validate_ingest(ingest_info, expected_info, metadata)
def testParse(self): controller = build_controller_for_tests(UsTxBrazosController, FIXTURE_PATH_PREFIX, run_async=False) args = ingest_args_for_fixture_file(controller, 'daily_data.csv') # pylint:disable=protected-access ingest_info = controller._parse(args, _ROSTER_PATH_CONTENTS) expected_info = IngestInfo( people=[ Person( person_id='12345', birthdate='8/10/1987 12:00:00 AM', gender='M ', race='White', place_of_residence='Brazos', bookings=[ Booking( booking_id='321', admission_date='3/31/2019 12:00:00 AM', custody_status= 'L. Pretrial State Jail Felons (SJF)', facility='BCDC', arrest=Arrest( agency="Brazos County Sheriff's Office"), charges=[ Charge( charge_id='1', offense_date='3/25/2019 12:00:00 AM', statute='481.121(B)(1) HSC', name='17.16 DET PEND ORD/POSS MARIJ <2OZ', degree='Class B Misdemeanor', charge_class='MIS', status='Intake', bond=Bond( bond_id='1', amount='2000.0000', bond_type='Surety Bond', status='Posted')), Charge( charge_id='2', offense_date='3/25/2019 12:00:00 AM', statute='483.041 HSC', name= '17.16 DET PEND ORD/POSS DANGEROUS DRUG', degree='Class A Misdemeanor', charge_class='MIS', status='Intake', bond=Bond( bond_id='2', amount='4000.0000', bond_type='Surety Bond', status='Posted')), Charge( charge_id='3', offense_date='1/20/2019 12:00:00 AM', statute='31.03(e)(2)(A)', name='THEFT PROP >=$100<$750', degree='Class B Misdemeanor', charge_class='MIS', status='Accepted'), Charge( charge_id='4', offense_date='3/30/2019 12:00:00 AM', statute='30.02(C)(1) PC', name='BURGLARY OF BUILDING', degree='State Jail Felony', charge_class='FEL', status='Warrant Issued'), Charge( charge_id='5', offense_date='3/25/2019 12:00:00 AM', statute='481.116(B) HSC', name='POSS CS PG 2 LESS THAN ONE GRAM', degree='State Jail Felony', charge_class='FEL', status='Warrant Issued'), Charge( charge_id='6', offense_date='3/23/2019 12:00:00 AM', statute='30.02(C)(1) PC', name='BURGLARY OF BUILDING', degree='State Jail Felony', charge_class='FEL', status='Warrant Issued'), Charge( charge_id='7', offense_date='3/24/2019 12:00:00 AM', statute='30.02(C)(1) PC', name='BURGLARY OF BUILDING', degree='State Jail Felony', charge_class='FEL', status='Warrant Issued')])]), Person( person_id='23456', birthdate='2/21/1982 12:00:00 AM', gender='M ', race='Black', place_of_residence='Brazos', bookings=[ Booking( booking_id='432', admission_date='5/14/2018 12:00:00 AM', custody_status= 'L. Pretrial State Jail Felons (SJF)', facility='BCDC', arrest=Arrest( agency="Brazos County Sheriff's Office"), charges=[ Charge( charge_id='8', statute='NA', name='Parole Violation/Bl/Wrnt/tty', degree='Felony Unassigned', charge_class='FEL'), Charge( charge_id='9', offense_date='5/14/2018 12:00:00 AM', statute='38.04(B)(1) PC', name='EVADING ARREST DET W/PREV CONVICTION', degree='State Jail Felony', charge_class='FEL', status='Defendant Indicted'), Charge( charge_id='10', statute='NON REPORTABLE', name='Awaiting Trans To Dept State ' 'Health Services', degree='Not Applicable')], holds=[ Hold( jurisdiction_name='TDC Hold')])])]) region = regions.get_region('us_tx_brazos', is_direct_ingest=True) metadata = IngestMetadata( region.region_code, region.jurisdiction_id, _FAKE_START_TIME, controller.get_enum_overrides(), ) self.validate_ingest(ingest_info, expected_info, metadata)