当前位置: 首页>>代码示例>>Python>>正文


Python utils.number_of_errors函数代码示例

本文整理汇总了Python中tests.unit.dataactvalidator.utils.number_of_errors函数的典型用法代码示例。如果您正苦于以下问题:Python number_of_errors函数的具体用法?Python number_of_errors怎么用?Python number_of_errors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了number_of_errors函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ignored_and_failed_original_loan_subsidy_cost_values

def test_ignored_and_failed_original_loan_subsidy_cost_values(database):
    """ Tests that a single warning is thrown for both a federal action obligation of 0
        and an original loan subsidy cost of 0 """

    tas = _TAS
    afa = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
                                          original_loan_subsidy_cost='0', assistance_type='09')
    afa_2 = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
                                            original_loan_subsidy_cost='-2.3', assistance_type='09')
    afa_3 = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
                                            original_loan_subsidy_cost='2.3', assistance_type='08')
    af = AwardFinancialFactory(tas=tas, submisson_id=afa.submission_id, fain=None, uri=None)

    errors = number_of_errors(_FILE, database, models=[afa, af, afa_2, afa_3])
    assert errors == 3

    # Test that this is ignored if assistance type is 08
    afa = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
                                          original_loan_subsidy_cost='0', assistance_type='08')
    afa_2 = AwardFinancialAssistanceFactory(tas=tas, fain='abc', uri=None, federal_action_obligation=1,
                                            original_loan_subsidy_cost='-2.3', assistance_type='08')
    af = AwardFinancialFactory(tas=tas, submisson_id=afa.submission_id, fain=None, uri=None)

    errors = number_of_errors(_FILE, database, models=[afa, af, afa_2])
    assert errors == 0
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:25,代码来源:test_c9_award_financial.py

示例2: test_failure

def test_failure(database):
    """ Test invalid. For ActionType = A, the CFDA_Number must be active as of the ActionDate.
        Not apply to those with CorrectionLateDeleteIndicator = C.
        If publish_date > action_date > archive_date, reject that (not active).
    """

    cfda = CFDAProgram(program_number=12.340, published_date="20130427", archived_date="")
    det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20120111',
                                                          action_type='A', correction_late_delete_ind="B")
    det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20120111',
                                                          action_type='A', correction_late_delete_ind=None)
    det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20120111',
                                                          action_type='A', correction_late_delete_ind="B")
    det_award_4 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20120111',
                                                          action_type='A', correction_late_delete_ind=None)

    errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, det_award_4, cfda])
    assert errors == 4

    # test for cfda_number that doesn't exist in the table
    cfda = CFDAProgram(program_number=12.340, published_date="20130427", archived_date="")
    det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="54.321", action_date='20140111',
                                                          action_type='A', correction_late_delete_ind="B")
    det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="AB.CDE", action_date='20140111',
                                                          action_type='A', correction_late_delete_ind=None)
    det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="11.111", action_date='20130528',
                                                          action_type='B', correction_late_delete_ind="B")

    errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
    assert errors == 3
开发者ID:tony-sappe,项目名称:data-act-broker-backend,代码行数:30,代码来源:test_fabs37_detached_award_financial_assistance_1.py

示例3: test_failure

def test_failure(database):
    """ Test failure for unique PIID, or combination of PIID/ParentAwardId, from file C exists in file D1 during the
        same reporting period. Do not process if allocation transfer agency is not null and does not match agency ID """

    # Perform when there's a transaction obligated amount value in the field
    af = AwardFinancialFactory(piid='some_piid', parent_award_id='some_parent_award_id',
                               allocation_transfer_agency=None, transaction_obligated_amou='12345')
    ap = AwardProcurementFactory(piid='some_other_piid', parent_award_id='some_parent_award_id')

    assert number_of_errors(_FILE, database, models=[af, ap]) == 1

    # Perform when there's an ata in the field and it matches the aid
    af = AwardFinancialFactory(piid='some_piid', parent_award_id='some_parent_award_id',
                               allocation_transfer_agency='bad', agency_identifier='bad',
                               transaction_obligated_amou='12345')
    ap = AwardProcurementFactory(piid='some_piid', parent_award_id='some_other_parent_award_id')

    assert number_of_errors(_FILE, database, models=[af, ap]) == 1

    af = AwardFinancialFactory(piid='some_piid', parent_award_id=None,
                               allocation_transfer_agency='bad', agency_identifier='bad',
                               transaction_obligated_amou='12345')
    ap = AwardProcurementFactory(piid='some_other_piid', parent_award_id='some_other_parent_award_id')

    assert number_of_errors(_FILE, database, models=[af, ap]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:25,代码来源:test_c11_cross_file.py

示例4: test_failure

def test_failure(database):
    """ BusinessTypes must be one to three letters in length. BusinessTypes values must be non-repeated letters
        from A to X. """

    # Test if it's somehow empty or has 4 letters (length test)
    det_award = DetachedAwardFinancialAssistanceFactory(business_types="")
    det_award_2 = DetachedAwardFinancialAssistanceFactory(business_types="ABCD")

    errors = number_of_errors(_FILE, database, models=[det_award, det_award_2])
    assert errors == 2

    # Test repeats
    det_award = DetachedAwardFinancialAssistanceFactory(business_types="BOb")
    det_award_2 = DetachedAwardFinancialAssistanceFactory(business_types="BOB")
    det_award_3 = DetachedAwardFinancialAssistanceFactory(business_types="BbO")
    det_award_4 = DetachedAwardFinancialAssistanceFactory(business_types="BB")

    errors = number_of_errors(_FILE, database, models=[det_award, det_award_2, det_award_3, det_award_4])
    assert errors == 4

    # Test that only valid letters work
    det_award = DetachedAwardFinancialAssistanceFactory(business_types="ABY")
    det_award_2 = DetachedAwardFinancialAssistanceFactory(business_types="C2")

    errors = number_of_errors(_FILE, database, models=[det_award, det_award_2])
    assert errors == 2
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:26,代码来源:test_fabs18_detached_award_financial_assistance.py

示例5: test_failure

def test_failure(database):
    """ Test for USSGL 48XX & 49XX (except 487X & 497X) if any one is provided and
    by_direct_reimbursable_fun is empty the rule fails """

    op_dict = {'by_direct_reimbursable_fun': None, 'object_class': 123, 'ussgl480100_undelivered_or_fyb': None,
               'ussgl480100_undelivered_or_cpe': None, 'ussgl488100_upward_adjustm_cpe': None,
               'ussgl490100_delivered_orde_fyb': None, 'ussgl490100_delivered_orde_cpe': None,
               'ussgl498100_upward_adjustm_cpe': None, 'ussgl480200_undelivered_or_fyb': None,
               'ussgl480200_undelivered_or_cpe': None, 'ussgl488200_upward_adjustm_cpe': None,
               'ussgl490200_delivered_orde_cpe': None, 'ussgl490800_authority_outl_fyb': None,
               'ussgl490800_authority_outl_cpe': None, 'ussgl498200_upward_adjustm_cpe': None}

    keys = ['ussgl480100_undelivered_or_fyb', 'ussgl480100_undelivered_or_cpe',
            'ussgl488100_upward_adjustm_cpe', 'ussgl490100_delivered_orde_fyb',
            'ussgl490100_delivered_orde_cpe', 'ussgl498100_upward_adjustm_cpe',
            'ussgl480200_undelivered_or_fyb', 'ussgl480200_undelivered_or_cpe',
            'ussgl488200_upward_adjustm_cpe', 'ussgl490200_delivered_orde_cpe',
            'ussgl490800_authority_outl_fyb', 'ussgl490800_authority_outl_cpe',
            'ussgl498200_upward_adjustm_cpe']

    for i in range(len(keys)):
        op_dict_copy = copy.deepcopy(op_dict)
        op_dict_copy.pop(keys[i])
        op = ObjectClassProgramActivityFactory(**op_dict_copy)
        assert number_of_errors(_FILE, database, models=[op]) == 1

    op = ObjectClassProgramActivityFactory(by_direct_reimbursable_fun=None, object_class=123)
    assert number_of_errors(_FILE, database, models=[op]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:28,代码来源:test_b12_object_class_program_activity_1.py

示例6: test_failure

def test_failure(database):
    """ Test for USSGL 48XX & 49XX (except 487X & 497X) if any one is provided and
    by_direct_reimbursable_fun is empty the rule fails """

    af_dict = {'by_direct_reimbursable_fun': None, 'ussgl480100_undelivered_or_fyb': None,
               'ussgl480100_undelivered_or_cpe': None, 'ussgl488100_upward_adjustm_cpe': None,
               'ussgl490100_delivered_orde_fyb': None, 'ussgl490100_delivered_orde_cpe': None,
               'ussgl498100_upward_adjustm_cpe': None, 'ussgl480200_undelivered_or_fyb': None,
               'ussgl480200_undelivered_or_cpe': None, 'ussgl488200_upward_adjustm_cpe': None,
               'ussgl490200_delivered_orde_cpe': None, 'ussgl490800_authority_outl_fyb': None,
               'ussgl490800_authority_outl_cpe': None, 'ussgl498200_upward_adjustm_cpe': None}

    keys = ['ussgl480100_undelivered_or_fyb', 'ussgl480100_undelivered_or_cpe',
            'ussgl488100_upward_adjustm_cpe', 'ussgl490100_delivered_orde_fyb',
            'ussgl490100_delivered_orde_cpe', 'ussgl498100_upward_adjustm_cpe',
            'ussgl480200_undelivered_or_fyb', 'ussgl480200_undelivered_or_cpe',
            'ussgl488200_upward_adjustm_cpe', 'ussgl490200_delivered_orde_cpe',
            'ussgl490800_authority_outl_fyb', 'ussgl490800_authority_outl_cpe',
            'ussgl498200_upward_adjustm_cpe']

    # Takes out one required key at a time and check that we get exactly one
    # error
    for i in range(len(keys)):
        af_dict_copy = copy.deepcopy(af_dict)
        af_dict_copy.pop(keys[i])
        af = AwardFinancialFactory(**af_dict_copy)
        assert number_of_errors(_FILE, database, models=[af]) == 1

    af = AwardFinancialFactory(by_direct_reimbursable_fun=None)
    assert number_of_errors(_FILE, database, models=[af]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:30,代码来源:test_b12_award_financial_1.py

示例7: test_pubished_date_success

def test_pubished_date_success(database):
    """ Test valid. For (ActionType = B, C, or D), the CFDA_Number need NOT be active as of the ActionDate.
        Not apply to those with CorrectionDeleteIndicator = C.
        Active date: publish_date <= action_date <= archive_date (Fails validation if active).
    """

    cfda = CFDAProgram(program_number=12.340, published_date="20130427", archived_date="")
    det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20140528',
                                                          action_type='B', correction_delete_indicatr="B")
    det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20140428',
                                                          action_type='C', correction_delete_indicatr="D")
    det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.340", action_date='20140428',
                                                          action_type='D', correction_delete_indicatr=None)
    errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
    assert errors == 0

    cfda = CFDAProgram(program_number=12.350, published_date="20130427", archived_date="20140427")
    det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20130528',
                                                          action_type='B', correction_delete_indicatr="B")
    det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20130428',
                                                          action_type='C', correction_delete_indicatr="D")
    det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.350", action_date='20130428',
                                                          action_type='D', correction_delete_indicatr=None)
    errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
    assert errors == 0
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:25,代码来源:test_fabs37_detached_award_financial_assistance_2.py

示例8: test_pubished_date_failure

def test_pubished_date_failure(database):
    """ Test invalid. For (ActionType = B, C, or D), the CFDA_Number need NOT be active as of the ActionDate.
        Not apply to those with CorrectionLateDeleteIndicator = C.
        Active date: publish_date <= action_date <= archive_date (Fails validation if active).
        If action date is < published_date, should trigger a warning.
    """

    cfda = CFDAProgram(program_number="12.345", published_date="20130427", archived_date="")
    det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20120528',
                                                          action_type='B', correction_late_delete_ind="B")
    det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20120427',
                                                          action_type='C', correction_late_delete_ind="D")
    det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20120428',
                                                          action_type='D', correction_late_delete_ind=None)
    errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
    assert errors == 3

    cfda = CFDAProgram(program_number="12.345", published_date="20130427", archived_date="20140528")
    det_award_1 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20120528',
                                                          action_type='B', correction_late_delete_ind="B")
    det_award_2 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20150427',
                                                          action_type='C', correction_late_delete_ind="D")
    det_award_3 = DetachedAwardFinancialAssistanceFactory(cfda_number="12.345", action_date='20150428',
                                                          action_type='D', correction_late_delete_ind=None)
    errors = number_of_errors(_FILE, database, models=[det_award_1, det_award_2, det_award_3, cfda])
    assert errors == 3
开发者ID:tony-sappe,项目名称:data-act-broker-backend,代码行数:26,代码来源:test_fabs37_detached_award_financial_assistance_2.py

示例9: test_success

def test_success(database):
    """ Test for USSGL 48XX & 49XX (except 487X & 497X) if any one is provided then
    by_direct_reimbursable_fun is not empty """

    op = ObjectClassProgramActivityFactory()
    assert number_of_errors(_FILE, database, models=[op]) == 0

    op = ObjectClassProgramActivityFactory(object_class=1234, by_direct_reimbursable_fun=None)
    assert number_of_errors(_FILE, database, models=[op]) == 0
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:9,代码来源:test_b12_object_class_program_activity_1.py

示例10: test_success

def test_success(database):
    """ ObligationsDeliveredOrdersUnpaidTotal in File C = USSGL 4901 + 4981 in File C for the same date context
    (FYB) """

    af = AwardFinancialFactory(obligations_delivered_orde_fyb=None, ussgl490100_delivered_orde_fyb=None)

    assert number_of_errors(_FILE, database, models=[af]) == 0

    af = AwardFinancialFactory(obligations_delivered_orde_fyb=1, ussgl490100_delivered_orde_fyb=1)

    assert number_of_errors(_FILE, database, models=[af]) == 0
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:11,代码来源:test_c4_award_financial_2.py

示例11: test_failure

def test_failure(database):
    """ ObligationsUndeliveredOrdersUnpaidTotal in File C != USSGL 4801 + 4881 in File C for the same date context
    (FYB) """

    af = AwardFinancialFactory(obligations_undelivered_or_fyb=1, ussgl480100_undelivered_or_fyb=None)

    assert number_of_errors(_FILE, database, models=[af]) == 1

    af = AwardFinancialFactory(obligations_undelivered_or_fyb=1, ussgl480100_undelivered_or_fyb=2)

    assert number_of_errors(_FILE, database, models=[af]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:11,代码来源:test_c3_award_financial_2.py

示例12: test_failure

def test_failure(database):
    """ ObligationsDeliveredOrdersUnpaidTotal in File C != USSGL 4901 + 4981 in File C for the same date context
    (CPE) """

    af = AwardFinancialFactory(obligations_delivered_orde_cpe=1, ussgl490100_delivered_orde_cpe=None,
                               ussgl498100_upward_adjustm_cpe=None)

    assert number_of_errors(_FILE, database, models=[af]) == 1

    af = AwardFinancialFactory(obligations_delivered_orde_cpe=1, ussgl490100_delivered_orde_cpe=1,
                               ussgl498100_upward_adjustm_cpe=1)

    assert number_of_errors(_FILE, database, models=[af]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:13,代码来源:test_c4_award_financial_1.py

示例13: test_failure

def test_failure(database):
    """ Unique PIID, ParentAwardId from file D1 doesn't exist in file C during the same reporting period,
        except D1 records with zero FederalActionObligation """

    ap = AwardProcurementFactory(piid='some_piid', parent_award_id='some_parent_award_id', federal_action_obligation=1)
    af = AwardFinancialFactory(piid='some_other_piid', parent_award_id='some_parent_award_id')

    assert number_of_errors(_FILE, database, models=[af, ap]) == 1

    ap = AwardProcurementFactory(piid='some_piid', parent_award_id='some_parent_award_id', federal_action_obligation=1)
    af = AwardFinancialFactory(piid='some_piid', parent_award_id='some_other_parent_award_id')

    assert number_of_errors(_FILE, database, models=[af, ap]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:13,代码来源:test_c12_cross_file.py

示例14: test_failure

def test_failure(database):
    """ DeobligationsRecoveriesRefundsOfPriorYearByProgramObjectClass_CPE in File B != USSGL(4871+ 4872 + 4971 + 4972)
    in File B for the same reporting period """

    op = ObjectClassProgramActivityFactory(deobligations_recov_by_pro_cpe=1, ussgl487100_downward_adjus_cpe=None,
                                           ussgl487200_downward_adjus_cpe=None, ussgl497100_downward_adjus_cpe=None,
                                           ussgl497200_downward_adjus_cpe=None)

    assert number_of_errors(_FILE, database, models=[op]) == 1

    op = ObjectClassProgramActivityFactory(deobligations_recov_by_pro_cpe=1, ussgl487100_downward_adjus_cpe=1,
                                           ussgl487200_downward_adjus_cpe=1, ussgl497100_downward_adjus_cpe=1,
                                           ussgl497200_downward_adjus_cpe=1)

    assert number_of_errors(_FILE, database, models=[op]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:15,代码来源:test_b13_object_class_program_activity.py

示例15: test_failure

def test_failure(database):
    """ Test invalid object class code (3 digits) """

    # This should return because if it's '0000' '000', '00', '0' a warning should be returned
    af = AwardFinancialFactory(object_class='0000')
    assert number_of_errors(_FILE, database, models=[af]) == 1

    af = AwardFinancialFactory(object_class='000')
    assert number_of_errors(_FILE, database, models=[af]) == 1

    af = AwardFinancialFactory(object_class='00')
    assert number_of_errors(_FILE, database, models=[af]) == 1

    af = AwardFinancialFactory(object_class='0')
    assert number_of_errors(_FILE, database, models=[af]) == 1
开发者ID:fedspendingtransparency,项目名称:data-act-broker-backend,代码行数:15,代码来源:test_b11_award_financial_2.py


注:本文中的tests.unit.dataactvalidator.utils.number_of_errors函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。