def test_class_id_name_county_entity_sample(self): self.assertEqual('person_id', Person.get_class_id_name()) self.assertEqual('booking_id', Booking.get_class_id_name()) self.assertEqual('hold_id', Hold.get_class_id_name())
def test_get_entity_name_county_entity_sample(self): self.assertEqual('person', Person.new_with_defaults().get_entity_name()) self.assertEqual('booking', Booking.new_with_defaults().get_entity_name()) self.assertEqual('hold', Hold.new_with_defaults().get_entity_name())
def testConvert_FullIngestInfo_GeneratedIds(self): # Arrange metadata = IngestMetadata('REGION', _JURISDICTION_ID, _INGEST_TIME) ingest_info = IngestInfo() ingest_info.people.add(person_id='PERSON_ID_GENERATE', booking_ids=['BOOKING_ID_GENERATE']) ingest_info.bookings.add( booking_id='BOOKING_ID_GENERATE', arrest_id='ARREST_ID_GENERATE', hold_ids=['HOLD_ID_1_GENERATE', 'HOLD_ID_2_GENERATE'], charge_ids=['CHARGE_ID_GENERATE']) ingest_info.holds.add(hold_id='HOLD_ID_1_GENERATE', jurisdiction_name='jurisdiction') ingest_info.holds.add(hold_id='HOLD_ID_2_GENERATE', jurisdiction_name='jurisdiction') ingest_info.arrests.add(arrest_id='ARREST_ID_GENERATE', agency='PD') ingest_info.charges.add(charge_id='CHARGE_ID_GENERATE', name='DUI', bond_id='BOND_ID_GENERATE', sentence_id='SENTENCE_ID_GENERATE') ingest_info.bonds.add(bond_id='BOND_ID_GENERATE') ingest_info.sentences.add(sentence_id='SENTENCE_ID_GENERATE', is_life='True') result = self._convert_and_throw_on_errors(ingest_info, metadata) # Assert expected_result = [ Person.new_with_defaults( region='REGION', jurisdiction_id='JURISDICTION_ID', bookings=[ Booking.new_with_defaults( admission_date=_INGEST_TIME.date(), admission_date_inferred=True, first_seen_time=_INGEST_TIME, last_seen_time=_INGEST_TIME, custody_status=CustodyStatus.PRESENT_WITHOUT_INFO, arrest=Arrest.new_with_defaults(agency='PD'), holds=[ Hold.new_with_defaults( jurisdiction_name='JURISDICTION', status=HoldStatus.PRESENT_WITHOUT_INFO) ], charges=[ Charge.new_with_defaults( status=ChargeStatus.PRESENT_WITHOUT_INFO, name='DUI', bond=Bond.new_with_defaults( status=BondStatus.PRESENT_WITHOUT_INFO), sentence=Sentence.new_with_defaults( status=SentenceStatus.PRESENT_WITHOUT_INFO, is_life=True)) ]) ]) ] self.assertEqual(result, expected_result)
def test_get_id_county_entity_sample(self): self.assertEqual(123, Person.new_with_defaults(person_id=123).get_id()) self.assertEqual(456, Booking.new_with_defaults(booking_id=456).get_id()) self.assertEqual(789, Hold.new_with_defaults(hold_id=789).get_id()) self.assertIsNone(Charge.new_with_defaults().get_id())
def _drop_hold(hold: entities.Hold): if hold.status != HoldStatus.INFERRED_DROPPED: logging.debug("Dropping hold with id %s", hold.hold_id) hold.status = HoldStatus.INFERRED_DROPPED
def testConvert_FullIngestInfo_GeneratedIds(self): # Arrange metadata = IngestMetadata("REGION", _JURISDICTION_ID, _INGEST_TIME) ingest_info = IngestInfo() ingest_info.people.add( person_id="PERSON_ID_GENERATE", booking_ids=["BOOKING_ID_GENERATE"] ) ingest_info.bookings.add( booking_id="BOOKING_ID_GENERATE", arrest_id="ARREST_ID_GENERATE", hold_ids=["HOLD_ID_1_GENERATE", "HOLD_ID_2_GENERATE"], charge_ids=["CHARGE_ID_GENERATE"], ) ingest_info.holds.add( hold_id="HOLD_ID_1_GENERATE", jurisdiction_name="jurisdiction" ) ingest_info.holds.add( hold_id="HOLD_ID_2_GENERATE", jurisdiction_name="jurisdiction" ) ingest_info.arrests.add(arrest_id="ARREST_ID_GENERATE", agency="PD") ingest_info.charges.add( charge_id="CHARGE_ID_GENERATE", name="DUI", bond_id="BOND_ID_GENERATE", sentence_id="SENTENCE_ID_GENERATE", ) ingest_info.bonds.add(bond_id="BOND_ID_GENERATE") ingest_info.sentences.add(sentence_id="SENTENCE_ID_GENERATE", is_life="True") result = self._convert_and_throw_on_errors(ingest_info, metadata) # Assert expected_result = [ Person.new_with_defaults( region="REGION", jurisdiction_id="JURISDICTION_ID", bookings=[ Booking.new_with_defaults( admission_date=_INGEST_TIME.date(), admission_date_inferred=True, first_seen_time=_INGEST_TIME, last_seen_time=_INGEST_TIME, custody_status=CustodyStatus.PRESENT_WITHOUT_INFO, arrest=Arrest.new_with_defaults(agency="PD"), holds=[ Hold.new_with_defaults( jurisdiction_name="JURISDICTION", status=HoldStatus.PRESENT_WITHOUT_INFO, ) ], charges=[ Charge.new_with_defaults( status=ChargeStatus.PRESENT_WITHOUT_INFO, name="DUI", bond=Bond.new_with_defaults( status=BondStatus.PRESENT_WITHOUT_INFO ), sentence=Sentence.new_with_defaults( status=SentenceStatus.PRESENT_WITHOUT_INFO, is_life=True, ), ) ], ) ], ) ] self.assertEqual(result, expected_result)
def test_get_entity_name_county_entity_sample(self) -> None: self.assertEqual("person", Person.new_with_defaults().get_entity_name()) self.assertEqual("booking", Booking.new_with_defaults().get_entity_name()) self.assertEqual("hold", Hold.new_with_defaults().get_entity_name())
def test_class_id_name_county_entity_sample(self) -> None: self.assertEqual("person_id", Person.get_class_id_name()) self.assertEqual("booking_id", Booking.get_class_id_name()) self.assertEqual("hold_id", Hold.get_class_id_name())