Esempio n. 1
0
def test_validate_fr_lt_mh_mn(session, desc, valid, reg_type, message_content):
    """Assert that financing statement specific registration type validation works as expected."""
    # setup
    json_data = copy.deepcopy(FINANCING)
    json_data['type'] = reg_type
    if desc != DESC_EXCLUDES_LY:
        del json_data['lifeYears']
    if desc != DESC_INFINITY_INVALID:
        json_data['lifeInfinite'] = True
    else:
        json_data['lifeInfinite'] = False
    del json_data['trustIndenture']
    if desc != DESC_INCLUDES_GC:
        del json_data['generalCollateral']
    if desc == DESC_MISSING_VC:
        del json_data['vehicleCollateral']
    elif desc != DESC_VC_NOT_MH:
        json_data['vehicleCollateral'][0]['type'] = 'MH'

    error_msg = validator.validate(json_data)
    if valid:
        assert error_msg == ''
    elif message_content:
        # print(error_msg)
        assert error_msg != ''
        assert error_msg.find(message_content) != -1
Esempio n. 2
0
def test_validate_misc(session, desc, valid, reg_type, message_content):
    """Assert that financing statement miscellaneous class registration type validation works as expected."""
    # setup
    json_data = copy.deepcopy(FINANCING)
    json_data['type'] = reg_type
    del json_data['trustIndenture']
    if desc != DESC_INFINITY_INVALID:
        json_data['lifeInfinite'] = True
    else:
        json_data['lifeInfinite'] = False
    if desc != DESC_EXCLUDES_LY:
        del json_data['lifeYears']
    if reg_type != 'MN':
        del json_data['vehicleCollateral']
    else:
        del json_data['generalCollateral']
        json_data['vehicleCollateral'][0]['type'] = 'MH'

    error_msg = validator.validate(json_data)
    if valid:
        assert error_msg == ''
    elif message_content:
        print(error_msg)
        assert error_msg != ''
        assert error_msg.find(message_content) != -1
Esempio n. 3
0
def test_validate_excluded_type(session, desc, valid, reg_type):
    """Assert that financing statement excluded registration type validation works as expected."""
    # setup
    json_data = copy.deepcopy(FINANCING)
    json_data['type'] = reg_type
    error_msg = validator.validate(json_data)
    if valid:
        assert error_msg == ''
    else:
        # print(error_msg)
        assert error_msg != ''
        assert error_msg.find(validator.TYPE_NOT_ALLOWED) != -1
Esempio n. 4
0
def test_validate_authorization(session, desc, valid, message_content):
    """Assert that financing statement authorization received validation works as expected."""
    # setup
    json_data = copy.deepcopy(FINANCING)
    if desc == DESC_MISSING_AC:
        del json_data['authorizationReceived']
    elif desc == DESC_INVALID_AC:
        json_data['authorizationReceived'] = False

    # test
    error_msg = validator.validate(json_data)
    if valid:
        assert error_msg == ''
    elif message_content:
        assert error_msg != ''
        assert error_msg.find(message_content) != -1
Esempio n. 5
0
def test_validate_ppsa(session, desc, valid, message_content):
    """Assert that financing statement ppsa class registration type validation works as expected."""
    # setup
    for reg_type in PPSATypes:
        if reg_type.value != 'RL':
            json_data = copy.deepcopy(FINANCING)
            json_data['type'] = reg_type.value
            del json_data['trustIndenture']
            if desc == DESC_INCLUDES_OT_DESC:
                json_data['otherTypeDescription'] = 'TEST OTHER DESC'
            elif desc == DESC_INCLUDES_TI:
                json_data['trustIndenture'] = True
                if reg_type.value == 'SA':
                    message_content = None
            if desc != DESC_ALL_LIFE:
                del json_data['lifeYears']
            else:
                if reg_type.value in ('FR', 'LT', 'MH'):
                    message_content = validator.LY_NOT_ALLOWED
                else:
                    message_content = validator.LIFE_INVALID
            json_data['lifeInfinite'] = True

            if reg_type.value in ('FL', 'FA', 'FS'):
                del json_data['vehicleCollateral']
            else:
                del json_data['generalCollateral']
                json_data['vehicleCollateral'][0]['type'] = 'MH'

            if desc == DESC_INCLUDES_LA:
                json_data['lienAmount'] = '1000'
            if desc == DESC_INCLUDES_SD:
                json_data['surrenderDate'] = '2030-06-15T00:00:00-07:00'

            # print('REG TYPE: ' + str(json_data['type']))
            error_msg = validator.validate(json_data)
            if valid:
                assert error_msg == ''
            elif message_content:
                # print(error_msg)
                assert error_msg != ''
                assert error_msg.find(message_content) != -1
Esempio n. 6
0
def test_validate_md_pt_sc(session, desc, valid, reg_type, message_content):
    """Assert that new MD, PT, SC registration type validation works as expected."""
    # setup
    json_data = copy.deepcopy(FINANCING)
    json_data['type'] = reg_type
    del json_data['trustIndenture']
    if desc == DESC_MISSING_GC:
        del json_data['generalCollateral']
    if desc != DESC_INCLUDES_VC:
        del json_data['vehicleCollateral']
    json_data['lifeInfinite'] = True
    del json_data['lifeYears']

    error_msg = validator.validate(json_data)
    if valid:
        assert error_msg == ''
    elif message_content:
        print(error_msg)
        assert error_msg != ''
        assert error_msg.find(message_content) != -1
Esempio n. 7
0
def test_validate_crown(session, desc, valid, message_content):
    """Assert that financing statement crown charge class registration type validation works as expected."""
    # setup
    for reg_type in CrownChargeTypes:
        if validator.validate_allowed_type(reg_type.value) != '':
            continue

        json_data = copy.deepcopy(FINANCING)
        json_data['type'] = reg_type.value
        del json_data['trustIndenture']
        if reg_type.value == 'OT' and desc != DESC_MISSING_OT_DESC:
            json_data['otherTypeDescription'] = 'TEST OTHER DESC'
            message_content = None
        elif reg_type.value != 'OT' and desc == DESC_INCLUDES_OT_DESC:
            json_data['otherTypeDescription'] = 'TEST OTHER DESC'
        elif desc == DESC_MISSING_OT_DESC or desc == DESC_INCLUDES_OT_DESC:
            message_content = None
        if desc != DESC_EXCLUDES_LY:
            del json_data['lifeYears']
        if desc != DESC_INFINITY_INVALID:
            json_data['lifeInfinite'] = True
        else:
            json_data['lifeInfinite'] = False
        if desc == DESC_MISSING_GC:
            del json_data['generalCollateral']
        if desc != DESC_INCLUDES_VC:
            del json_data['vehicleCollateral']

        # print('REG TYPE: ' + str(json_data['type']))
        error_msg = validator.validate(json_data)
        if valid:
            assert error_msg == ''
        elif message_content:
            # print(error_msg)
            assert error_msg != ''
            assert error_msg.find(message_content) != -1
Esempio n. 8
0
def test_validate_rl(session, desc, valid, lien_amount, surrender_date,
                     message_content):
    """Assert that financing statement RL registration type validation works as expected."""
    # setup
    json_data = copy.deepcopy(FINANCING)
    json_data['type'] = model_utils.REG_TYPE_REPAIRER_LIEN
    del json_data['lifeYears']
    del json_data['lifeInfinite']
    del json_data['trustIndenture']
    if lien_amount is not None:
        json_data['lienAmount'] = lien_amount
    if surrender_date == 'valid':
        json_data['surrenderDate'] = model_utils.format_ts(
            model_utils.now_ts())
    elif surrender_date == 'old':
        json_data['surrenderDate'] = model_utils.format_ts(
            model_utils.today_ts_offset(22, False))
    elif surrender_date == '21':
        json_data['surrenderDate'] = model_utils.format_ts(
            model_utils.now_ts_offset(21, False))
    elif surrender_date == 'junk':
        json_data['surrenderDate'] = 'invalid date'
    if desc != DESC_INCLUDES_GC:
        del json_data['generalCollateral']
    if desc == DESC_MISSING_VC:
        del json_data['vehicleCollateral']
    elif desc == DESC_VC_MH:
        json_data['vehicleCollateral'][0]['type'] = 'MH'

    error_msg = validator.validate(json_data)
    if valid:
        assert error_msg == ''
    elif message_content:
        # print(error_msg)
        assert error_msg != ''
        assert error_msg.find(message_content) != -1
Esempio n. 9
0
def validate_financing(json_data):
    """Perform non-schema extra validation on a financing statement."""
    error_msg = party_validator.validate_financing_parties(json_data)
    error_msg += financing_validator.validate(json_data)
    return error_msg