def test_matchHolds(self):
        db_hold = entities.Hold.new_with_defaults(hold_id=_ID,
                                                  jurisdiction_name=_NAME)
        db_hold_to_drop = entities.Hold.new_with_defaults(
            hold_id=_ID_ANOTHER, jurisdiction_name=_NAME_2)
        ingested_hold = entities.Hold.new_with_defaults(
            jurisdiction_name=_NAME)
        ingested_hold_new = entities.Hold.new_with_defaults(
            jurisdiction_name=_NAME_3)

        db_booking = entities.Booking.new_with_defaults(
            holds=[db_hold, db_hold_to_drop])
        ingested_booking = entities.Booking.new_with_defaults(
            holds=[ingested_hold, ingested_hold_new])

        expected_matched_hold = attr.evolve(ingested_hold,
                                            hold_id=db_hold.hold_id)
        expected_new_hold = attr.evolve(ingested_hold_new)
        expected_dropped_hold = attr.evolve(db_hold_to_drop,
                                            status=HoldStatus.INFERRED_DROPPED)

        county_entity_matcher.match_holds(db_booking=db_booking,
                                          ingested_booking=ingested_booking)

        self.assertCountEqual(
            ingested_booking.holds,
            [expected_matched_hold, expected_dropped_hold, expected_new_hold],
        )
Exemple #2
0
    def test_matchHolds_duplicateMatch_throws(self):
        db_hold = entities.Hold.new_with_defaults(
            hold_id=_ID, jurisdiction_name=_NAME)
        ingested_hold = entities.Hold.new_with_defaults(jurisdiction_name=_NAME)
        ingested_hold_another = attr.evolve(ingested_hold)

        db_booking = entities.Booking.new_with_defaults(holds=[db_hold])
        ingested_booking = entities.Booking.new_with_defaults(
            holds=[ingested_hold, ingested_hold_another])

        with self.assertRaises(EntityMatchingError):
            county_entity_matcher.match_holds(
                db_booking=db_booking, ingested_booking=ingested_booking)