Beispiel #1
0
    def testParseBond(self):
        # Arrange
        ingest_bond = ingest_info_pb2.Bond(
            bond_id="BOND_ID",
            bond_type="CASH",
            amount="$125.00",
            status="ACTIVE",
            bond_agent="AGENT",
        )

        # Act
        result = bond.convert(ingest_bond, _EMPTY_METADATA)

        # Assert
        expected_result = entities.Bond(
            external_id="BOND_ID",
            bond_type=BondType.CASH,
            bond_type_raw_text="CASH",
            amount_dollars=125,
            status=BondStatus.SET,
            status_raw_text="ACTIVE",
            bond_agent="AGENT",
        )

        self.assertEqual(result, expected_result)
Beispiel #2
0
    def testParseBond_AmountIsBondDenied_UsesAmountAsType(self):
        # Arrange
        ingest_bond = ingest_info_pb2.Bond(amount="Bond Denied")

        # Act
        result = bond.convert(ingest_bond, _EMPTY_METADATA)

        # Assert
        expected_result = entities.Bond.new_with_defaults(
            bond_type=BondType.DENIED, status=BondStatus.SET)
        self.assertEqual(result, expected_result)
Beispiel #3
0
    def testParseBond_OnlyAmount_InfersCash(self):
        # Arrange
        ingest_bond = ingest_info_pb2.Bond(amount='1,500')

        # Act
        result = bond.convert(ingest_bond, _EMPTY_METADATA)

        # Assert
        expected_result = entities.Bond.new_with_defaults(
            bond_type=BondType.CASH,
            status=BondStatus.PRESENT_WITHOUT_INFO,
            amount_dollars=1500)
        self.assertEqual(result, expected_result)
Beispiel #4
0
    def testParseBond_MapStatusToType(self):
        # Arrange
        ingest_bond = ingest_info_pb2.Bond(bond_type="bond revoked")
        overrides_builder = EnumOverrides.Builder()
        overrides_builder.add("BOND REVOKED", BondStatus.REVOKED, BondType)
        overrides = overrides_builder.build()

        # Act
        result = bond.convert(
            ingest_bond, attr.evolve(_EMPTY_METADATA,
                                     enum_overrides=overrides))

        # Assert
        expected_result = entities.Bond.new_with_defaults(
            bond_type_raw_text="BOND REVOKED", status=BondStatus.REVOKED)
        self.assertEqual(result, expected_result)